应该怎么这些比较回报
问题说明
我已经得到了多数民众赞成使用的String.Compare(字符串,字符串)在一定值进行排序的应用程序。我想不通的事情是为什么1022比较小于10-23和10-23比喻为小于1024。
I've got an application that's using string.compare(string,string) to sort some values. The thing I can't figure out is why "1022" compares as less than "10-23" and "10-23" compares as less than "1024".
有没有具体的有价值的东西 - 这会导致这样的结果?会的String.Compare那过载产生相同的结果与(与破折号号)相同的数据类型不同的区域性设置?
Is there something specific to the value of "-" that causes this result? Will that overload of string.compare give the same result with different culture settings for the same type of data (numbers with dashes)?
正确答案
的比较是使用单词排序规则来执行。
The comparison is performed using word sort rules.
和进一步:
.NET框架使用三个不同的排序方式:字排序,字符串排序,并依次排序。字排序执行字符串的文化敏感的比较。一些非字母数字字符可能分配给他们特殊的权重。例如,连字符( - )可能具有分配给它的一个非常小的重量,使鸡舍和合作社彼此相邻出现在排序列表。字符串排序类似于字排序,但没有特殊的情况下。因此,所有非字母数字符号来之前,所有字母数字字符。基于字符串的每个元素的统一code值依次排序比较字符串。
The .NET Framework uses three distinct ways of sorting: word sort, string sort, and ordinal sort. Word sort performs a culture-sensitive comparison of strings. Certain nonalphanumeric characters might have special weights assigned to them. For example, the hyphen ("-") might have a very small weight assigned to it so that "coop" and "co-op" appear next to each other in a sorted list. String sort is similar to word sort, except that there are no special cases. Therefore, all nonalphanumeric symbols come before all alphanumeric characters. Ordinal sort compares strings based on the Unicode values of each element of the string.
这是迈克尔·卡普兰在这里更多的细节: A和排序键,部分的对9(又名不总是传递的,而是准时,划分)。
Some more details from Michael Kaplan here: A&P of Sort Keys, part 9 (aka Not always transitive, but punctual and punctuating) .
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfgaae
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22