If you have an string array like this:
string[] s = {"bbb", "ccc", "aaa"};
The shorter way to sort it, using:
Array.Sort(s);
and the long way to sort it, using:
for (var i = 1; i < s.Length; i++)
{
for (var j = 0; j < s.Length - i; j++)
{
if (string.Compare(s[j], s[j + 1], StringComparison.Ordinal) <= 0) continue;
var temp = s[j];
s[j] = s[j + 1];
s[j + 1] = temp;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…