GNU bug report logs -
#65342
In Ubuntu 22.04 (unlike 20.04), sorting doesn't work properly
Previous Next
Reported by: Pl B <platon.new10 <at> gmail.com>
Date: Wed, 16 Aug 2023 17:33:02 UTC
Severity: normal
Tags: notabug
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
tag 65342 notabug
close 65342
stop
more info below...
On 16/08/2023 16:55, Pl B wrote:
> Source file:
> rs1009150173,100202244031
> rs1009150172,13853975996
> rs1009150170,54321425962
> rs1009150171,11378896079
> rs1009150,171582090052
>
> Ubuntu 20.04.5:
> sort -t ',' /path/to/rs_srt_exp.txt
> rs1009150,171582090052
> rs1009150170,54321425962
> rs1009150171,11378896079
> rs1009150172,13853975996
> rs1009150173,100202244031
> (correct order)
>
> elementary OS 7 (Ubuntu 22.04.3):
> sort -t ',' /path/to/rs_srt_exp.txt
> rs1009150170,54321425962
> rs1009150171,11378896079
> rs1009150,171582090052
> rs1009150172,13853975996
> rs1009150173,100202244031
> (wrong order)
>
> Python 3.10.12:
> with open('/path/to/rs_srt_exp.txt') as src_file_opened:
> for elem in sorted(map(lambda line: line.rstrip().split(','),
> src_file_opened)):
> print(elem)
> ['rs1009150', '171582090052']
> ['rs1009150170', '54321425962']
> ['rs1009150171', '11378896079']
> ['rs1009150172', '13853975996']
> ['rs1009150173', '100202244031']
> (correct order)
-t is ineffective without -k
I suspect the differing orders were due to locale differences.
To get expected ordering you probably want something like:
sort -t ',' -k1.3,1n -k2,2n
Note the --debug option is useful for identifying how sort is operating.
cheers,
Pádraig
This bug report was last modified 1 year and 281 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.