Natural sort order

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by StuartCheshire (talk | contribs) at 18:40, 13 May 2020 (Added references to Dave Koelle’s Alphanum Algorithm and Martin Pool’s Natural Order String Comparison). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are treated atomically, i.e., as if they were a single character. Natural sort order has been promoted as being more human-friendly ("natural") than the machine-oriented pure alphabetical order.[1]

For example, in alphabetical sorting "z11" would be sorted before "z2" because "1" is sorted as smaller than "2", while in natural sorting "z2" is sorted before "z11" because "2" is sorted as smaller than "11".

Alphabetical sorting:

  1. z11
  2. z2

Natural sorting:

  1. z2
  2. z11

The Natural Order Mac OS System Extension was conceived and implemented overnight on-site as an entry for the Best Hack contest during the 1996 MacHack conference in Dearborn, Michigan.[2][3]

Dave Koelle wrote the Alphanum Algorithm in 1997[4] and Martin Pool published Natural Order String Comparison in 2000.[5]

Functionality to sort by natural sort order is now built into many programming languages and libraries.[6][7][8][9]

References

  1. ^ "Sorting for Humans : Natural Sort Order". blog.codinghorror.com.
  2. ^ "Natural Order Numerical Sorting".
  3. ^ "TidBITS: The Natural Order of Things".
  4. ^ "Dave Koelle's Alphanum Algorithm".
  5. ^ "Martin Pool's Natural Order String Comparison".
  6. ^ "PHP: natsort - Manual". php.net.
  7. ^ "Sort::Naturally - search.cpan.org". search.cpan.org.
  8. ^ Morton, Seth M. "natsort: Simple yet flexible natural sorting in Python" – via PyPI.
  9. ^ "Customizable Natural-Order Sort - File Exchange - MATLAB Central".

External links