bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7961: sort


From: Assaf Gordon
Subject: bug#7961: sort
Date: Wed, 02 Feb 2011 13:50:35 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100918 Icedove/3.1.4

On a somewhat off-topic note,

Francesco Bettella wrote, On 02/02/2011 07:42 AM:
> 
> I'm issuing the following sort commands (see attached files):
> [prompt1] > sort -k 1.4,1n asd1 > asd1.sorted
> [prompt2] > sort -k 2.4,2n asd2 > asd2.sorted
> 
> the first one works as I would expect, the second one doesn't.

When sorting chromosome names, the version sort option (-V, introduced in 
coreutils 7.0) sorts as you would expect,
saving you the need to skip three characters in the sort key, and also 
accommodating mixing letters and numbers.

Example:

$ cat chrom.txt
chr1
chrUn_gl000232
chrY
chr2
chr13
chrM
chrUn_gl000218
chr6_hap
chr2R
chr16
chr10
chr6_dbb_hap3
chr4
chr3L
chr4_ctg9_hap1
chr3R
chr3
chrX

$ sort -k1,1V chrom.txt
chr1
chr2
chr2R
chr3
chr3L
chr3R
chr4
chr4_ctg9_hap1
chr6_dbb_hap3
chr6_hap
chr10
chr13
chr16
chrM
chrUn_gl000218
chrUn_gl000232
chrX
chrY


-gordon






reply via email to

[Prev in Thread] Current Thread [Next in Thread]