我有包含了像排序是不正确的格式
1.Script_DBScript_03122014
我想排序这个数组,所以我写了下面的代码文件名的String数组:
Array.Sort(SQLScripts);
但数组排序产生这样的:
1.Script_DBScript(otherdetails)_03122014
10.Script_DBScript(otherdetails)_03122014
11.Script_DBScript(otherdetails)_03122014
12.Script_DBScript(otherdetails)_03122014
...
2.Script_DBScript(otherdetails)_03122014
20.Script_DBScript(otherdetails)_03122014
21.Script_DBScript(otherdetails)_03122014
22.Script_DBScript(otherdetails)_03122014
... so on
我怎样才能在阵列中以下形式
1.Script_DBScript(otherdetails)_03122014
2.Script_DBScript(otherdetails)_03122014
3.Script_DBScript(otherdetails)_03122014
4.Script_DBScript(otherdetails)_03122014
5.Script_DBScript(otherdetails)_03122014
...
50.Script_DBScript(otherdetails)_03122014
编辑: 代码从目录中检索文件名:你得到
String[] SQLScripts = Directory.GetFiles(txtPath.Text, "*.sql");
默认情况下,字符串按字母顺序排序。这通常通过调整文件名来解决,例如, '0001.Script_DBScript_03122014'。这也是为什么一些文件名使用YYYYMMDD这样的日期格式,即2014年3月13日的20140313,或同一天的2:57:01 PM的20140313_145701。 – Peter
[自然排序顺序在C#](http://stackoverflow.com/questions/248603/natural-sort-order-in-c-sharp) – Oliver
可能重复的一些实现看看[排序为人类:自然排序顺序](http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/) – Oliver