/** * Sort function for sorting in ascending order * @param a - The numeric value of the first object to be sorted * @param b - The numeric value of the second object to be sorted * @return The sort value */ export declare const sortAsc: (a: number, b: number) => number; /** * Sort function for sorting in descending order * @param a - The numeric value of the first object to be sorted * @param b - The numeric value of the second object to be sorted * @return The sort value */ export declare const sortDesc: (a: number, b: number) => number; /** * Return a list of indices sorted by the array * * @example * const X = [9, 5, 11, -1, 0]; * const sortedIdx = argSort(X); * // >> [3, 4, 1, 0, 2] * // I.e., the smallest element is X[sortedIdx[0]] == -1 * * @param array - Array of numerical values * @param options - Option object * @param options.getter - Value getter * @param options.comparator - Pairwise value comparator function * @param options.ignoreNull - If `true` ignore `null` values * @return Array of indices sorted by the values */ export declare const argSort: (array: number[], { getter, comparator, ignoreNull, }?: { getter?: (x: number) => number; comparator?: (a: number, b: number) => number; ignoreNull?: boolean; }) => number[]; /** * Return the sort position of each element in an array or object * * @example * ```js * let array = [9, 5, 11, -1, 0]; * let pos = sortPos(array) * // >> [3, 2, 4, 0, 1] * // I.e., the first element of `array` is at the forth position (`3`) * * let object = { 1: 9, 2: 5, 11: 11, 100: -1, 999: 0 }; * let pos = sortPos(object) * // >> { 1: 3, 2: 2, 11: 4, 100: 0, 999: 1 } * // I.e., the `999`th element of `object` is at the second position (`1`) * ``` * * @param ource - Array or object of numerical values * @param options - Option object * @param options.getter - Value getter * @param options.comparator - Sort function * @param options.ignoreNull - If `true` ignore `null` values * @return Array or object of the sorted value positions */ export declare const sortPos: (source: number[] | Record, { getter, comparator, ignoreNull, }?: { getter?: (x: number) => number; comparator?: (a: number, b: number) => number; ignoreNull?: boolean; }) => number[] | Record;