Gnu/coreutils/Other-version 002fnatural-sort-implementations
From Get docs
Next: Related Source code, Previous: Reporting bugs or incorrect results, Up: Advanced Topics [Contents][Index]
30.4.3 Other version/natural sort implementations
As previously mentioned, there are multiple variations on version/natural sort, each with its own rules. Some examples are:
- Natural Sorting variants in Rosetta Code.
- Python’s natsort package (includes detailed description of their sorting rules: natsort - how it works).
- Ruby’s version_sorter.
- Perl has multiple packages for natual and version sorts (each likely with its own rules and nuances): Sort::Naturally, Sort::Versions, CPAN::Version.
- PHP has a built-in function natsort.
- NodeJS’s natural-sort package.
- In zsh, the glob modifier
*(n)
will expand to files in natural sort order. - When writing
C
programs, the GNU libc library (glibc
) provides the strvercmp(3) function to compare two strings, and versionsort(3) function to compare two directory entries (despite the names, they are not identical to GNU coreutils’ version sort ordering). - Using Debian’s sorting algorithm in:
- python: Stack Overflow Example #4957741.
- NodeJS: deb-version-compare.