1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 中一维数组按一定规则的排序 – PHP基础 – 前端 php操作sql

中一维数组按一定规则的排序 – PHP基础 – 前端 php操作sql

时间:2023-03-16 20:08:42

相关推荐

中一维数组按一定规则的排序 – PHP基础 – 前端 php操作sql

//思路:首先,将源数据筛选,并分别添加到两个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

{

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。