on master help sign in
Add sort function.

Evan did 95% of the work, but forgot about the F2 wrapper.

commit03256bc797cea79c5736b1c95aa88da910ff1181 authorMax Goldstein <maxgoldstein1@gmail.com> dateThu 7 Nov 2013, 18:47 (13 years ago) parent3ce4b09
2 files changed+9−2
libraries/List.elm+7 libraries/Native/List.js+2−2
libraries/List.elm+7
@@ -20,6 +20,9 @@ list must have the same type.
2020
2121# Special Folds
2222@docs sum, product, maximum, minimum, all, any, and, or
23+
24+# Sorting
25+@docs sort
2326-}
2427
2528import open Basics
@@ -224,3 +227,7 @@ drop = Native.List.drop
224227-}
225228repeat : Int -> a -> [a]
226229repeat = Native.List.repeat
230+
231+{-| Sort a list in ascending order. -}
232+sort : [comparable] -> [comparable]
233+sort = Native.List.sort
libraries/Native/List.js+2−2
@@ -214,8 +214,8 @@ Elm.Native.List.make = function(elm) {
214214
215215 function sort(xs) {
216216 function cmp(a,b) {
217− var ord = Utils.compare(a,b).ctor;
218− return ord=== 'EQ' ? 0 : ord === 'LT' ? -1 : 1;
217+ var ord = Utils.compare(a)(b).ctor;
218+ return ord === 'EQ' ? 0 : ord === 'LT' ? -1 : 1;
219219 }
220220 return fromArray(toArray(xs).sort(cmp));
221221 }