1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 01:37:19 +00:00

Merge pull request #1046 from dressupgeekout/charlotte_sort_doc

Explicitly mention that `sort-by` sorts a list in place.
This commit is contained in:
Calvin Rose 2022-12-16 11:11:07 -06:00 committed by GitHub
commit 57e6ee963d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -839,15 +839,15 @@
a)
(defn sort
``Sort `ind` in-place, and return it. Uses quick-sort and is not a stable sort.
``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 `<`.``
[ind &opt before?]
(sort-help ind 0 (- (length ind) 1) (or before? <)))
(defn sort-by
``Returns `ind` sorted by calling
a function `f` on each element and comparing the result with `<`.``
``Sorts `ind` in-place by calling a function `f` on each element and
comparing the result with `<`.``
[f ind]
(sort ind (fn [x y] (< (f x) (f y)))))