public static JsArray <T> OrderBy <T>(this JsArray <T> array, JsFunc <T, object> selector, bool desc) { var array2 = array.slice(0); if (!desc) { array2.sort((x, y) => Compare(selector(x), selector(y))); } else { array2.sort((x, y) => CompareDesc(selector(x), selector(y))); } return(array2); }