Terminology - What does alphanumeric order mean in relation to decimals? It is also called Natural sort order.


  "It's hard to find information on natural sorting"-Jeff Atwood on Coding Horror.   


And it seems true today as the Wikipedia entry seems pretty bare.

Definition 1: Non-numeric word-character substrings are sorted lexically, case-insensitively. Numeric substrings are sorted numerically. non words-characters, non-digits are ignored.

Definition 2: Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are ordered as a single character.

The main difference is that Definition 1 allows decimals while Definition 2 does not. For example I have the list ["t8.1", "t8.11", "t8.2", "t7.2", "t7.11"].

Definition 1 would yeild: ["t7.11", "t7.2", "t8.1", "t8.11", "t8.2"].

Definition 2 would yeild: ["t7.2", "t7.11", "t8.1", "t8.2", "t8.11"].

Python's natsorted function was definition 1 until v4.0.0 and now uses realsorted for this behavior. Python's natsorted function currently follows definition 2.

Perl follows definition 1 (which is where I found it. 

Php follows definition 2

MATLAB uses definition 2 for non-version numbers.

Dave Koelle implements definition 1 for his examples but says it's a 'glitch' and thus supporting definition 2 as correct. In most the linked code, the code treats '.' as a string but what if it was a decimal in a numeric substring? Dave Koelle notes this as a glitch by saying "There is currently a glitch when it comes to periods/decimal points - specifically, periods are treated only as strings, not as decimal points.".

To me, the word numeric would imply decimals but in practice it seems that this is not the case unless specifically noted to include decimals.

What does Alphanumberic/Natural Order Sort mean exactly without additional qualifiers? For example: In "Natural Order Sort with decimals", "with decimals" would be an additional qualifiers. Which definition is correct for "Natural Order Sort"? 

Alphanumberic (Non-Decimal) vs Alphanumberic (Decimal)
Alphanumeric sort means that every character is compared according to ascii representation.
Natural sort treats consecutive digits as one chatacter, so actually compares as integer. There is no place for decimals, but when you compare two numbers in the form $X.Y &gt; W.Z$ it looks like decimal compare.

So what does "natural sort does not compare decimals" really mean?
The example above is just coincidence, like reading month.day as float and sorting will give good order, but adding and subtracting is not defined. Same here, "-" will not be identified as part of decimal, so comparison will be shifted. The separator might be given as anything, but will change results when inconsistent.