Skip to content

Commit

Permalink
Explain properties of the lt keyword for sorting (JuliaLang#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 and johanmon committed Jul 5, 2021
1 parent af45fd2 commit 7e626dc
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 7e626dc

Please sign in to comment.