Se estiver usando o GNU sort
ou compatível, você pode usar a opção -g
para fazer uma classificação numérica geral:
$ sort -g -k5,5 file
name: yyy --- time: 3.2 seconds
name: xxx --- time: 5.4 seconds
name: zzz --- time: 6.4 seconds
O -k5,5
diz ao sort para realizar a classificação apenas na quinta coluna.
Uso
Lembre-se dos detalhes da página info sort
:
'--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.