public static void Sort <T>(T[] array, Comparison <T> cmpFunc) { var needConvert = !(array.instanceof <JsArray>()); JsArray sortArray; if (needConvert) { sortArray = new JsArray(array.Length); for (var i = 0; i < array.Length; i++) { sortArray[i] = array[i]; } } else { sortArray = array.As <JsArray>(); } if (cmpFunc == null) { cmpFunc = Comparer <T> .Default.Compare; } if (cmpFunc == null) { sortArray.sort(); } else { sortArray.sort(cmpFunc.As <JsFunction>()); } if (!needConvert) { return; } for (var i = 0; i < array.Length; i++) { array[i] = sortArray[i].As <T>(); } }
public static Func <T, T, int> AsFunction <T>([NotNull] this Comparison <T> comparison) { return(comparison.As <Func <T, T, int> >()); }
public void Sort(Comparison <T> comparison) { _list.sort(comparison.As <JsFunction>()); }