Why doesn't **sort** sort the same on every machine?

后端 未结 4 1120
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 21:28

Using the same sort command with the same input produces different results on different machines. How do I fix that?

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 22:03

    For more than you ever wanted to know about sort, read the specification of sort in the Single Unix Specification v3. It states

    Comparisons [...] shall be performed using the collating sequence of the current locale.

    IOW, how sort sorts is dependent on the locale (language) settings of the environment that the script is running under.

提交回复
热议问题