coreutils
[Top][All Lists]
Advanced

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

Re: question on using the -n option for sorting


From: Pádraig Brady
Subject: Re: question on using the -n option for sorting
Date: Sun, 3 Nov 2024 10:31:46 +0000
User-agent: Mozilla Thunderbird Beta

On 03/11/2024 01:48, American Citizen wrote:
Hello:

I am a number theory mathematician, using linux as a computer platform
for my studies.

In using the sort command with the -n option, such as the command

%sort -k3,3n close.2 > close.3

I noticed that the 93 digits in the 3rd field are NOT numerically
ordered, although most were.

I switched to the dictionary order

%sort -k3,3 close.2 > close.3

and then close.3 seems to be in the correct numerical sequence in field 3.

Can anyone share with me how many digits the -n option can safely sort?
Can we do decimals > 17 digits with this option? Can sort be
strengthened to handle digits > 17 ?

Thank you for letting me know. I attach a short 100 line sample file
which was extracted from the 29,984 line actual close.2 file.

Randall

I'm not seeing the issue with sort 9.4 at least.
Stripping the insignificant leading zeros I can more easily
see the correct sorting being applied:

  cut -f3 example.sort | sed 's/^0*//' | sort -n

What version of sort(1) are you using?

In any case, GNU `sort -n` does not convert numbers to machine representation,
so can sort numbers of arbitrary width.

thanks,
Pádraig



reply via email to

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