Per the man pages we have the following description of the --numeric-sort option of the sort command.
-n, --numeric-sort
compare according to string numerical value
I assume, by string numeric value, we mean comparing each string character consecutively by its ASCII value?
The info pages read
‘-n’
‘--numeric-sort’
‘--sort=numeric’
Sort numerically. The number begins each line and consists of
optional blanks, an optional ‘-’ sign, and zero or more digits
possibly separated by thousands separators, optionally followed by
a decimal-point character and zero or more digits. An empty number
is treated as ‘0’. The ‘LC_NUMERIC’ locale specifies the
decimal-point character and thousands separator. By default a
blank is a space or a tab, but the ‘LC_CTYPE’ locale can change
this.
Comparison is exact; there is no rounding error.
Neither a leading ‘+’ nor exponential notation is recognized. To
compare such strings numerically, use the ‘--general-numeric-sort’
(‘-g’) option.
After reading both docs, I still do not see explicitly explained which collation order is used for the -n option.
How does the --numeric-sort option differ from the default? My naive guess would be that numbers take precedence over letters, but I am not reading this in the documentation.
And which documentation states this explicitly, i.e. where could I have found this info by just looking up the documentation?
printf %s\\n 111 10 2 22
... first time usesort
thensort -n
(the latter meaning sort by arithmetic value)info
page... "An empty number is treated as ‘0’" and "Finally, as a last resort when all keys compare equal, ‘sort’ compares entire lines as if no ordering options other than ‘--reverse’ (‘-r’) were specified." soprintf %s\\n b2 a3 | sort -n
is the same asprintf %s\\n 0b2 0a3 | sort