Reputation: 4470
I have a file ( 3 columns tab delimited), I need to check if file is sorted or not Example:
chr1 9999999 10000125 C57T3ANXX:7:2114:14205:58915/2 50 -
chr1 10010918 10011044 C57T3ANXX:7:2310:08814:31632/1 50 +
chr1 10011185 10011311 C57T3ANXX:7:2310:08814:31632/2 50 -
On above file, I use
cut -f1,2 f |sort -cn,
which give me
sort: -:2: disorder: chr1 10010918.
I am not sure why, as the file is already sorted. I get same order when I use
sort -k1,1 -k2,2 f
Upvotes: 1
Views: 405
Reputation: 1808
sort -cn
assumes that the entire line is the key, because the line starts with a non-numeric character it resorts to non-numeric mode for that key, which is the only one
enable numeric mode for you keys:
sort -k1,1 -k2,2 -cn
Upvotes: 3