使用Unix排序科学编号 [英] Sorting Scientific Number With Unix Sort
本文介绍了使用Unix排序科学编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试用Unix排序对这些数字进行排序,但似乎不起作用:
I tried to sort these number with Unix sort, but it doesn't seem to work:
2e-13
1e-91
2e-13
1e-104
3e-19
9e-99
这是我的命令:
sort -nr file.txt
什么是正确的方法?
推荐答案
使用-g
(长格式--general-numeric-sort
)代替-n
. -g
选项将数字通过strtod
传递以获得其值,它将识别这种格式.
Use -g
(long form --general-numeric-sort
) instead of -n
. The -g
option passes the numbers through strtod
to obtain their value, and it will recognize this format.
我不确定这是否在sort
的所有实现中可用,或者仅在GNU的实现中可用.
I'm not sure if this is available on all implementations of sort
, or just the GNU one.
这篇关于使用Unix排序科学编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文