for (int i = 0; i < str.Length; i += 2) //按两位拆分原字符串
{
string num = str[i].ToString() + str[i + 1].ToString();//将两位字符组成一个新的字符串
numArray.Add(num); //将新的字符串放进字符串集合
}
for (int i = 0; i < numArray.Count - 1; i++) //冒泡排序字符串集合
{
for (int j = 0; j < numArray.Count - 1; j++)
{
if (int.Parse(numArray[j])>int.Parse(numArray[j+1]))
{
string buffer = numArray[j];
numArray[j] = numArray[j + 1];
numArray[j + 1] = buffer;
}
}
}
string newstring="";
for (int i = 0; i < numArray.Count; i++) //拼接新字符串
{
newstring += numArray[i];
}