Sort numeric order

Hi
I am using this

cat substitutionFeats.txt | gawk '{$0=gensub(/\t/,"blabla",1);print}' | gawk '{print length, $0}' | sort -n | sort -r

and the "sort -n" command doesn't work as expected: it leads to a wrong ordering:

64 Adjustable cuffs
64 Abrasion-
64 Abrasion pas
647 Sanitized 647 Sanitized 
64 2 zippered 
63 two side lat�rales
63 two side lat�rales
63 stretch pa
63 stretch pa

I though "-n" was the good option for sort....any idea what is wrong?

thanks

You should combine -n and -r into single sort:

cat substitutionFeats.txt | gawk '{$0=gensub(/\t/,"blabla",1);print}' | gawk '{print length, $0}' | sort -rn 
1 Like

Try:

sort -k1,1rn -k2r
1 Like

combining r and n options works fine. thanks!

finally I chose

sort -k1,1rn -k2r

thanks