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