source: node_modules/ramda/es/sort.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 986 bytes
Line 
1import _curry2 from "./internal/_curry2.js";
2/**
3 * Returns a copy of the list, sorted according to the comparator function,
4 * which should accept two values at a time and return a negative number if the
5 * first value is smaller, a positive number if it's larger, and zero if they
6 * are equal. Please note that this is a **copy** of the list. It does not
7 * modify the original.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.1.0
12 * @category List
13 * @sig ((a, a) -> Number) -> [a] -> [a]
14 * @param {Function} comparator A sorting function :: a -> b -> Int
15 * @param {Array} list The list to sort
16 * @return {Array} a new array with its elements sorted by the comparator function.
17 * @see R.ascend, R.descend
18 * @example
19 *
20 * const diff = function(a, b) { return a - b; };
21 * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]
22 */
23
24var sort =
25/*#__PURE__*/
26_curry2(function sort(comparator, list) {
27 return Array.prototype.slice.call(list, 0).sort(comparator);
28});
29
30export default sort;
Note: See TracBrowser for help on using the repository browser.