中一维数组按一定规则的排序?
//思路:首先,将源数据筛选,并分别添加到两个list中;
// 然后,将两个list分别排序;
// 最后,将排序好的list,循环添加到字符串数组中
try
{
//源数据
string[] mxmlfiles = { "mart900_0102.xml", "matr550_01024.xml", "mart900_0101.xml", "matr550_01025.xml" };
//分别存mart900和matr550开头的数据
List
List
for (int i = 0; i
{
//注意mnewstring的值
string mnewstring = mxmlfiles[i].Substring(0, 7);
if (string.Equals("mart900", mnewstring, StringComparison.CurrentCultureIgnoreCase))
{
listmart900.Add(mxmlfiles[i]);
}
else if (string.Equals("matr550", mnewstring, StringComparison.CurrentCultureIgnoreCase))
{
listmatr550.Add(mxmlfiles[i]);
}
}
//两个list分别排序
listmart900.Sort();
listmatr550.Sort();
string[] resultmart900 = new string[listmart900.Count];
for (int i = 0; i
{
resultmart900[i] = listmart900[i];
}
//listmatr550的数据你自己处理一下,呵呵~~~
}
catch
{
}
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有