JanetDocsPlaygroundI'm feeling luckyGitHub sign in

sort



    function
    boot.janet on line 794, column 1

    (sort a &opt by)

    Sort an array in-place. Uses quick-sort and is not a stable sort.


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