public void Sort(T[] keys, int index, int length, IComparer <T> comparer) { try { if (comparer == null || comparer == Comparer <T> .Default) { if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5) { GenericArraySortHelper <T> .IntrospectiveSort(keys, index, length); } else { GenericArraySortHelper <T> .DepthLimitedQuickSort(keys, index, length + index - 1, 32); } } else if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5) { ArraySortHelper <T> .IntrospectiveSort(keys, index, length, comparer); } else { ArraySortHelper <T> .DepthLimitedQuickSort(keys, index, length + index - 1, comparer, 32); } } catch (IndexOutOfRangeException ex) { IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer((object)comparer); } catch (Exception ex) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), ex); } }