📌  相关文章
📜  C#代码示例中的大排序hackerrank解决方案

📅  最后修改于: 2022-03-11 14:48:46.598000             🧑  作者: Mango

代码示例1
int n = Convert.ToInt32(Console.ReadLine());
string[] a = new string[n];
for (int i = 0; i < n; i++) 
    a[i] = Console.ReadLine();

Array.Sort(a, (left, right) => {
    if (left.Length != right.Length)
        return left.Length - right.Length;
    else
        return string.CompareOrdinal(left, right); // left.CompareTo(right) is too slow
});
for (int i = 0; i < n; i++) 
    Console.WriteLine(a[i]);