Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sort bibliographies by authors' last names.

(Tweaked by Vincent.)
  • Loading branch information...
commit 3caf0aca23a293271dd7245f42b28dccaab535f6 1 parent a475c07
@ianj ianj authored stamourv committed
View
16 collects/scriblib/autobib.rkt
@@ -161,12 +161,16 @@
(define render-date-bib (or maybe-render-date-bib default-render-date-bib))
(define render-date-cite (or maybe-render-date-cite default-render-date-cite))
(define (author/date<? a b)
- ;; comparing just the authors causes non-deterministic render order. Use entire key.
- (or (string-ci<? (auto-bib-key a) (auto-bib-key b))
- (and (string-ci=? (auto-bib-key a) (auto-bib-key b))
- (auto-bib-date a)
- (auto-bib-date b)
- (date<? a b))))
+ ;; comparing just the authors causes non-deterministic render order.
+ ;; We still have to use the authors first in order for last name order.
+ ;; If there is a collision for names, then disambiguate with the keys and then the date.
+ (or (string-ci<? (extract-bib-key a) (extract-bib-key b))
+ (and (string-ci=? (extract-bib-key a) (extract-bib-key b))
+ (or (string-ci<? (auto-bib-key a) (auto-bib-key b))
+ (and (string-ci=? (auto-bib-key a) (auto-bib-key b))
+ (auto-bib-date a)
+ (auto-bib-date b)
+ (date<? a b))))))
(define (ambiguous? a b)
(and (string-ci=? (extract-bib-key a) (extract-bib-key b))
(auto-bib-date a)
View
19 collects/tests/scribble/docs/autobib-order.scrbl
@@ -0,0 +1,19 @@
+#lang scribble/base
+@(require scriblib/autobib)
+@(define-cite cite citet gen)
+
+@(define a (make-bib #:title "Diss 1"
+ #:is-book? #t
+ #:location (dissertation-location #:institution "NEU")
+ #:author (authors (author-name "Little Bo" "Peep") (author-name "Samwise" "Gamgee"))
+ #:date "2012"))
+@(define b (make-bib #:title "Diss 2"
+ #:is-book? #t
+ #:location (dissertation-location #:institution "NEU")
+ #:author (authors (author-name "Ayo" "Shucks"))
+ #:date "2012"))
+Order matters. Must sort by last names.
+@cite[b]
+@cite[a]
+
+@(gen)
View
7 collects/tests/scribble/docs/autobib-order.txt
@@ -0,0 +1,7 @@
+Order matters. Must sort by last names.  (Shucks 2012)  (Peep and Gamgee
+2012)
+
+Bibliography
+
+Little Bo Peep and Samwise Gamgee. Diss 1. PhD dissertation, NEU, 2012.
+Ayo Shucks. Diss 2. PhD dissertation, NEU, 2012.
View
6 collects/tests/scribble/docs/autobib.txt
@@ -10,8 +10,8 @@ al. 2010, part II)  (Felleisen et al. 2010)
Bibliography
And no date. Look ma, no authors.
-Dorai Sitaram. Programming in Schelog. 1993.
-http://www.ccs.neu.edu/~dorai/schelog/schelog.html
-Look ma, no authors.
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics
Engineering with PLT Redex. MIT Press, 2010.
+Look ma, no authors.
+Dorai Sitaram. Programming in Schelog. 1993.
+http://www.ccs.neu.edu/~dorai/schelog/schelog.html
Please sign in to comment.
Something went wrong with that request. Please try again.