JanetDocsPlaygroundI'm feeling luckyGitHub sign in

sort



    function
    boot.janet on line 841, column 1

    (sort ind &opt before?)

    Sorts `ind` in-place, and returns it. Uses quick-sort and is not a 
    stable sort. If a `before?` comparator function is provided, sorts 
    elements using that, otherwise uses `<`.


See also:sort-bysorted2 examplesSign in to add an example
Loading...
(def a @[[42 "c"] [68 "b"] [31 "d"] [27 "a"]])
(sort a (fn [a b]
          (< (a 1) (b 1))))
(pp a) # @[(27 "a") (68 "b") (42 "c") (31 "d")]
uvtcPlayground
(sort @[5 4 1 3 2])   # -> @[1 2 3 4 5]
(sort @[5 4 1 3 2] >) # -> @[5 4 3 2 1]
felixrPlayground