Skip to content

Commit

Permalink
Explain properties of the lt keyword for sorting (#41029)
Browse files Browse the repository at this point in the history
* Explain restrictions on lt functions

* Remove warn block, add note in text
  • Loading branch information
sostock authored Jun 2, 2021
1 parent 3ec7824 commit 6be3652
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ Sort the vector `v` in place. [`QuickSort`](@ref) is used by default for numeric
[`MergeSort`](@ref) is used for other arrays. You can specify an algorithm to use via the `alg`
keyword (see [Sorting Algorithms](@ref) for available algorithms). The `by` keyword lets you provide
a function that will be applied to each element before comparison; the `lt` keyword allows
providing a custom "less than" function; use `rev=true` to reverse the sorting order. These
providing a custom "less than" function (note that for every `x` and `y`, only one of `lt(x,y)`
and `lt(y,x)` can return `true`); use `rev=true` to reverse the sorting order. These
options are independent and can be used together in all possible combinations: if both `by`
and `lt` are specified, the `lt` function is applied to the result of the `by` function;
`rev=true` reverses whatever ordering specified via the `by` and `lt` keywords.
Expand Down

0 comments on commit 6be3652

Please sign in to comment.