Function: bibtex-lessp
bibtex-lessp is a byte-compiled function defined in bibtex.el.gz.
Signature
(bibtex-lessp INDEX1 INDEX2)
Documentation
Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2.
Each index is a list (KEY CROSSREF-KEY ENTRY-TYPE).
The predicate depends on the variable bibtex-maintain-sorted-entries.
If its value is nil use plain sorting.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
(defun bibtex-lessp (index1 index2)
"Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2.
Each index is a list (KEY CROSSREF-KEY ENTRY-TYPE).
The predicate depends on the variable `bibtex-maintain-sorted-entries'.
If its value is nil use plain sorting."
(cond ((not index1) (not index2)) ; indices can be nil
((not index2) nil)
((consp bibtex-maintain-sorted-entries)
(funcall (cadr bibtex-maintain-sorted-entries) index1 index2))
((eq bibtex-maintain-sorted-entries 'crossref)
;; CROSSREF-KEY may be nil or it can point to an entry
;; in another BibTeX file. In both cases we ignore CROSSREF-KEY.
(if (and (nth 1 index1)
(cdr (assoc-string (nth 1 index1) bibtex-reference-keys)))
(if (and (nth 1 index2)
(cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
(or (string-lessp (nth 1 index1) (nth 1 index2))
(and (string-equal (nth 1 index1) (nth 1 index2))
(string-lessp (nth 0 index1) (nth 0 index2))))
(not (string-lessp (nth 0 index2) (nth 1 index1))))
(if (and (nth 1 index2)
(cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
(string-lessp (nth 0 index1) (nth 1 index2))
(string-lessp (nth 0 index1) (nth 0 index2)))))
((eq bibtex-maintain-sorted-entries 'entry-class)
(let ((n1 (cdr (or (assoc (nth 2 index1) bibtex-sort-entry-class-alist)
(assoc 'catch-all bibtex-sort-entry-class-alist)
'(nil . 1000)))) ; if there is nothing else
(n2 (cdr (or (assoc (nth 2 index2) bibtex-sort-entry-class-alist)
(assoc 'catch-all bibtex-sort-entry-class-alist)
'(nil . 1000))))) ; if there is nothing else
(or (< n1 n2)
(and (= n1 n2)
(string-lessp (car index1) (car index2))))))
(t ; (eq bibtex-maintain-sorted-entries 'plain)
(string-lessp (car index1) (car index2)))))