I\'m having trouble writing a method that returns true if the elements of an array (numbers) are in sorted order, ascending or descending, and false, if they are not in any
Using Linq -
public static bool IsArraySorted(int[] numbers) { var orderedAsc = numbers.OrderBy(a => a); var orderedDes = numbers.OrderByDescending(a => a); bool isSorted = numbers.SequenceEqual(orderedAsc) || numbers.SequenceEqual(orderedDes); return isSorted; }