# Terminology - What does alphanumeric order mean in relation to decimals?

It is also called Natural sort order.

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

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.

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"?

• Er, um... blogs don't tend to write themselves. Why not give credit to the author instead of the blog? Jul 12, 2016 at 16:16
• I would like to add.. what if there are special character in the name too like #1.txt. So if we ask sort alphanumerically will they count too. Jul 12, 2016 at 21:25
• Are you asking on a computer science site how programmers call things?
– Raphael
Jul 12, 2016 at 21:25
• It is "alphanumeric" without "b". I see the ambiguous problem. There are more definitions, but please read it more carefully. Natural sort is used exactly as I described definition. The parts where extended decimals with sign are used is called "natural real sort", it takes floating point numbers from string. (Real here is also bad definition, since the floating points with fixed length are used). Per language extension gives for example case-insensitive comparisons. It is not shown in examples, but what happens with different notations? 1e299, 0x34 or 0777? So "scientific natural order"?
– Evil
Jul 13, 2016 at 21:47
• So straight from definition without examples or language specific implementations the natural order was like in the blog created to handle non-zero-padded integers (just like in the blog example). This is recognized definition. The other definitions are different types of sort with less known names, or not recognized by name (but recognized by "in language X compiler/interpreter version Y+" works like this). The glitch is in fact according to definition proper - "." is char. The other names are not well recognized (easily checked by Google toss).
– Evil
Jul 13, 2016 at 21:53

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 > W.Z$ it looks like decimal compare.