Sorting Scientific Number With Unix Sort

后端 未结 4 1761
面向向阳花
面向向阳花 2021-02-02 12:12

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

This is

4条回答
  •  走了就别回头了
    2021-02-02 12:49

    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.

    I'm not sure if this is available on all implementations of sort, or just the GNU one.

提交回复
热议问题