aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/sort.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/sort.el')
-rw-r--r--lisp/sort.el21
1 files changed, 0 insertions, 21 deletions
diff --git a/lisp/sort.el b/lisp/sort.el
index 4f0d759ef8a..2ee76b6e1e3 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -478,27 +478,6 @@ sRegexp specifying key within record: \nr")
478 ;; if there was no such register 478 ;; if there was no such register
479 (error (throw 'key nil)))))))))) 479 (error (throw 'key nil))))))))))
480 480
481;;;###autoload
482(defun sort-on (sequence predicate accessor)
483 "Sort SEQUENCE by calling PREDICATE on sort keys produced by ACCESSOR.
484SEQUENCE should be the input sequence to sort.
485Elements of SEQUENCE are sorted by keys which are obtained by
486calling ACCESSOR on each element. ACCESSOR should be a function of
487one argument, an element of SEQUENCE, and should return the key
488value to be compared by PREDICATE for sorting the element.
489PREDICATE is the function for comparing keys; it is called with two
490arguments, the keys to compare, and should return non-nil if the
491first key should sort before the second key.
492The return value is always a new list.
493This function has the performance advantage of evaluating
494ACCESSOR only once for each element in the input SEQUENCE, and is
495therefore appropriate when computing the key by ACCESSOR is an
496expensive operation. This is known as the \"decorate-sort-undecorate\"
497paradigm, or the Schwartzian transform."
498 (mapcar #'car
499 (sort (mapcar #'(lambda (x) (cons x (funcall accessor x))) sequence)
500 #'(lambda (x y) (funcall predicate (cdr x) (cdr y))))))
501
502 481
503(defvar sort-columns-subprocess t) 482(defvar sort-columns-subprocess t)
504 483