List<int> list = new List<int>(){4,2,3,42,21,0,3};
string str = "";
int count =0;
for (int i = 0; i < list.Count; i++)
{
for (int j = i; j < list.Count; j++)
{
if(list[i]>list[j])
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
count++;
}
}
}
for (int i = 0; i < list.Count; i++)
{
str += list[i]+",";
}
Debug.Log(str + " 计数:"+count);