coreutils
[Top][All Lists]
Advanced

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

Re: Is natural sort supported?


From: Peng Yu
Subject: Re: Is natural sort supported?
Date: Tue, 8 Oct 2019 02:44:20 -0500

> At the risk of arguing over semantics,
> I'll say again: there is no "one correct" natural order standard,
> and therefore it is not "plain and simple" because there is no just
> "one" such order.

I don't think there is no commonly accepted "natural sort". For
example, I found another one that uses the same order as the python
one that I showed above. The so-called version sort in corutils' sort
is just not natural sort and it should not be called natural sort.

$ printf '%s\n' G . | csvtk sort -k 1:N
G
.
$ printf '%s\n' 1G 1. | csvtk sort -k 1:N
1G
1.
$ printf '%s\n' 1G13 1.02 | csvtk sort -k 1:N
1G13
1.02

Wikipedia also explains what natural sort is and provided a few
implementation links. I don't think any of them implemented the
version sort as the natural sort.

https://en.wikipedia.org/wiki/Natural_sort_order

> and note that even the above blog writes:
> "... Don't let Ned's clever Python ten-liner fool you. Implementing a
> natural sort is more complex than it seems ... ".

I don't understand this sentence. There is an implementation with just
a few lines in python. Unless this implementation is wrong, then there
is a simple implementation at least in python.

-- 
Regards,
Peng



reply via email to

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