1

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

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any way to fix it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.