Skip to content

Commit

Permalink
Sort bibliographies by authors' last names.
Browse files Browse the repository at this point in the history
(Tweaked by Vincent.)
  • Loading branch information
J. Ian Johnson authored and stamourv committed Apr 5, 2012
1 parent a475c07 commit 3caf0ac
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
16 changes: 10 additions & 6 deletions collects/scriblib/autobib.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions collects/tests/scribble/docs/autobib-order.scrbl
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions collects/tests/scribble/docs/autobib-order.txt
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions collects/tests/scribble/docs/autobib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3caf0ac

Please sign in to comment.