unix sort -n -t"," gives unexpected result
I'm not sure this is entirely correct, but it's close.
sort -n -t,
will try to sort numerically by the given key(s). In this case, the key is a tuple consisting of an integer and a float. Such tuples cannot be sorted numerically.
If you explicitly specify which single keys to sort on with
sort -k1,1n -k2,2n -t,
it should work. Now you are explicitly telling sort
to first sort on the first field (numerically), then on the second field (also numerically).
I suspect that -n
is useful as a global option only if each line of the input consists of a single numerical value. Otherwise, you need to use the -n
option in conjunction with the -k
option to specify exactly which fields are numbers.
Use sort --debug to find out what's going on.I've used that to explain in detail your issue at:http://lists.gnu.org/archive/html/coreutils/2013-10/msg00004.html