Da página de informações de sort
, a classificação -g
é explicada por estes
‘-g’
‘--general-numeric-sort’
‘--sort=general-numeric’
Sort numerically, converting a prefix of each line to a long
double-precision floating point number. *Note Floating point::.
Do not report overflow, underflow, or conversion errors. Use the
following collating sequence:
• Lines that do not start with numbers (all considered to be
equal).
• NaNs (“Not a Number” values, in IEEE floating point
arithmetic) in a consistent but machine-dependent order.
• Minus infinity.
• Finite numbers in ascending numeric order (with -0 and +0
equal).
• Plus infinity.
Use this option only if there is no alternative; it is much slower
than ‘--numeric-sort’ (‘-n’) and it can lose information when
converting to floating point.
sort -n
é o tipo natural que normalmente esperamos
‘-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.
Verifique a resposta da Steeldriver para obter uma explicação melhor.