JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

sort-by

core-api


    function
    boot.janet on line 1058, column 1

    (sort-by f x)

    Sorts `x` in-place by calling a function `f` on each element and 
    comparing the results with `<`.

    `x` can be a buffer, array, or abstract type with suitable `get`, 
    `put`, and `length` methods.


1 exampleSign in to add an example
Loading...
(sort-by
  (fn [x] (get x :b))
   @[{:a 1 :b 100} {:a 100 :b 1} {:a -1 :b 50}])

# -> @[{:a 100 :b 1} {:a -1 :b 50} {:a 1 :b 100}]
felixrPlayground