Skip to content

Commit 0a21171

Browse files
authored
Remove implementation details from sort_by
1 parent 3f1e222 commit 0a21171

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/elixir/lib/enum.ex

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,22 +2218,15 @@ defmodule Enum do
22182218
function.
22192219
22202220
This function maps each element of the enumerable using the provided `mapper`
2221-
function. The enumerable is then sorted by the mapped elements
2222-
using the `sorter` function, which defaults to `Kernel.<=/2`
2221+
function. The enumerable is then sorted by the mapped elements
2222+
using the `sorter` function, which defaults to `Kernel.<=/2`.
22232223
22242224
`sort_by/3` differs from `sort/2` in that it only calculates the
22252225
comparison value for each element in the enumerable once instead of
22262226
once for each element in each comparison.
2227-
If the same function is being called on both element, it's also more
2227+
If the same function is being called on both elements, it's also more
22282228
compact to use `sort_by/3`.
22292229
2230-
This technique is also known as a
2231-
_[Schwartzian Transform](https://en.wikipedia.org/wiki/Schwartzian_transform)_,
2232-
or the _Lisp decorate-sort-undecorate idiom_ as the `mapper`
2233-
is decorating the original `enumerable`; then `sorter` is sorting the
2234-
decorations; and finally the enumerable is being undecorated so only
2235-
the original elements remain, but now in sorted order.
2236-
22372230
## Examples
22382231
22392232
Using the default `sorter` of `<=/2`:

0 commit comments

Comments
 (0)