I tried this:
$ echo "2,3435,1" | sort -n
2,3435,1
$ sort -t',' -n test_sort.txt
kill,gill,burger
110,20,30,13
$ cat test_sort.txt
110,20,30,13
kill,gill,burger
Why doesn't my sort
command work?
My desired sort
command should work like this:
$sort -t',' -n test_sort.txt
110,13,20,30,burger,gill,kill
ANSWER : tr , '\n' < a | sort -n | paste -sd, -
"Thanks to Stéphane Chazelas"
-t
specifies what separates fields, butsort
re-orders rows of data. It just references fields in determining what value to sort by.tr , '\n' < a | sort -n | paste -sd, -