[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils-bug
Subject:    bug#65342: In Ubuntu 22.04 (unlike 20.04), sorting doesn't work properly
From:       Pádraig Brady <P () draigBrady ! com>
Date:       2023-08-16 18:07:56
Message-ID: adc671a5-a1c8-4a45-379e-86cee337b89b () draigBrady ! com
[Download RAW message or body]

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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic