考虑到从一个非常大的函数返回的数组.
fastest如果对数组进行排序,测试的方法是什么?
最简单的方法是:
/// <summary>
/// Determines if int array is sorted from 0 -> Max
/// </summary>
public static bool IsSorted(int[] arr)
{
for (int i = 1; i < arr.Length; i++)
{
if (arr[i - 1] > arr[i])
{
return false;
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)