Commit bf091062 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Improve documentation of 'sort-subr'

* doc/lispref/text.texi (Sorting): Clarify the meaning and use of
PREDICATE argument to 'sort-subr'.  (Bug#41706)
parent 73749efa
Pipeline #5769 passed with stage
in 60 minutes and 16 seconds
......@@ -2028,8 +2028,15 @@ non-@code{nil} value.
@end enumerate
The argument @var{predicate} is the function to use to compare keys.
If keys are numbers, it defaults to @code{<}; otherwise it defaults to
It is called with two arguments, the keys to compare, and should
return non-@code{nil} if the first key should come before the second
in the sorting order. What exactly are the key arguments depends on
what @var{startkeyfun} and @var{endkeyfun} return. If @var{predicate}
is omitted or @code{nil}, it defaults to @code{<} if the keys are
numbers, to @code{compare-buffer-substrings} if the keys are cons
cells (whose @code{car} and @code{cdr} are start and end buffer
positions of the key), and to @code{string<} otherwise (with keys
assumed to be strings).
As an example of @code{sort-subr}, here is the complete function
definition for @code{sort-lines}:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment