当前位置:   article > 正文

c# 字典按ascii 排序,C#区分大小写的ASCII排序?

c# ascii区分大小写排序

i need to sort an string Array and it MUST be sorted by ascii.

if using Array.Sort(myArray), it won't work.

for example:

myArray is ("aAzxxxx","aabxxxx")

if using Array.Sort(myArray)

the result will be

aabxxxx

aAzxxxx

but if ascii sort, because A < a, (capital A is 65, a is 97, so A < a)

the result will be

aAzxxxx

aabxxxx

this is the result i need. any ideas about how to ASCII sort an string Array?

thx

解决方案

If I have understood you correctly, you want to perform an Ordinal comparison.

Array.Sort(myArray, StringComparer.Ordinal);

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号