GNU bug report logs - #7961
sort

Previous Next

Package: coreutils;

Reported by: Francesco Bettella <francesb <at> decode.is>

Date: Wed, 2 Feb 2011 14:42:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Francesco Bettella <francesb <at> decode.is>
Cc: 7961 <at> debbugs.gnu.org
Subject: bug#7961: sort
Date: Wed, 02 Feb 2011 13:50:35 -0500
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





This bug report was last modified 14 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.