for (int j = 0; j < files.Length - 1;j++ )
for (int i = 0; i < files.Length - 1 - j; i++)
{
string bubble = files[i];
if (files[i].CompareTo(files[i + 1]) > 0)
{
string temp = files[i];
files[i] = files[i + 1];
files[i + 1] = temp;
}
for (int i = 0; i < files.Length - 1 - j; i++)
{
string bubble = files[i];
if (files[i].CompareTo(files[i + 1]) > 0)
{
string temp = files[i];
files[i] = files[i + 1];
files[i + 1] = temp;
}
}
先写内循环,在写外循环比较顺思路。