为什么不** **排序排序每台机器上一样吗? [英] Why doesn't **sort** sort the same on every machine?

查看:174
本文介绍了为什么不** **排序排序每台机器上一样吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用相同的排序以相同的输入命令产生不同机器上的不同的结果。我该如何解决呢?

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

推荐答案

的<一个href=\"http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/sort.1.html\">man-page在OS X上说:

*** 警告 *** 由环境所指定的语言环境会影响排序顺序。设置LC_ALL = C来获得
  使用本地字节值的传统排序顺序。

*** WARNING *** The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values.

这或许可以解释的事情。

which might explain things.

如果您的某些系统没有语言环境的支持,他们将默认为是区域(C),这样你就不必把它放在那些。如果你有一些支持语言环境并要相同的行为,设置 LC_ALL = C 在这些系统上。这将是有尽可能多的系统的方式,因为我知道这样做同样的方式。

If some of your systems have no locale support, they would default to that locale (C), so you wouldn't have to set it on those. If you have some that supports locales and want the same behavior, set LC_ALL=C on those systems. That would be the way to have as many systems as I know do it the same way.

如果你没有任何语言环境不太系统,只是确保他们共享区域很可能是不够的。

If you don't have any locale-less systems, just making sure they share locale would probably be enough.

有关更多规范的信息,请参阅单一UNIX®规范的区域 2版介绍, 环境变量中的 setlocale()的排序的说明(1)工具

For more canonical information, see the The Single UNIX ® Specification, Version 2 description of locale, environment variables, setlocale() and the description of the sort(1) utility.

这篇关于为什么不** **排序排序每台机器上一样吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆