Natural sort order
In computing, natural sort order (or natural sorting) is a way of ordering strings that treats embedded numbers as whole numerical values rather than sequences of characters.
While standard alphabetical order compares strings character-by-character (where "10" sorts before "2" because "1" is less than "2"), natural sort order orders them by magnitude of the number, placing "2" before "10".
Natural sort order is designed to address the shortcoming of standard lexicographical order, which often produces counter-intuitive results for humans when dealing with numbered lists, filenames, or version numbers.
| Natural | Lexicographical |
|---|---|
| 1.jpg
2.jpg 3.jpg 9.jpg 10.jpg 11.jpg |
1.jpg
10.jpg 11.jpg 2.jpg 3.jpg 9.jpg |