Skip to content
This repository
Browse code

Sort bibliographies by authors' last names.

(Tweaked by Vincent.)
  • Loading branch information...
commit 3caf0aca23a293271dd7245f42b28dccaab535f6 1 parent a475c07
J. Ian Johnson authored April 03, 2012 stamourv committed April 05, 2012
16  collects/scriblib/autobib.rkt
@@ -161,12 +161,16 @@
161 161
   (define render-date-bib (or maybe-render-date-bib default-render-date-bib))
162 162
   (define render-date-cite (or maybe-render-date-cite default-render-date-cite))
163 163
   (define (author/date<? a b)
164  
-    ;; comparing just the authors causes non-deterministic render order. Use entire key.
165  
-    (or (string-ci<? (auto-bib-key a) (auto-bib-key b))
166  
-        (and (string-ci=? (auto-bib-key a) (auto-bib-key b))
167  
-             (auto-bib-date a)
168  
-             (auto-bib-date b)
169  
-             (date<? a b))))
  164
+    ;; comparing just the authors causes non-deterministic render order.
  165
+    ;; We still have to use the authors first in order for last name order.
  166
+    ;; If there is a collision for names, then disambiguate with the keys and then the date.
  167
+    (or (string-ci<? (extract-bib-key a) (extract-bib-key b))
  168
+        (and (string-ci=? (extract-bib-key a) (extract-bib-key b))
  169
+             (or (string-ci<? (auto-bib-key a) (auto-bib-key b))
  170
+                 (and (string-ci=? (auto-bib-key a) (auto-bib-key b))
  171
+                      (auto-bib-date a)
  172
+                      (auto-bib-date b)
  173
+                      (date<? a b))))))
170 174
   (define (ambiguous? a b)
171 175
     (and (string-ci=? (extract-bib-key a) (extract-bib-key b))
172 176
          (auto-bib-date a)
19  collects/tests/scribble/docs/autobib-order.scrbl
... ...
@@ -0,0 +1,19 @@
  1
+#lang scribble/base
  2
+@(require scriblib/autobib)
  3
+@(define-cite cite citet gen)
  4
+
  5
+@(define a (make-bib #:title "Diss 1"
  6
+                     #:is-book? #t
  7
+                     #:location (dissertation-location #:institution "NEU")
  8
+                     #:author (authors (author-name "Little Bo" "Peep") (author-name "Samwise" "Gamgee"))
  9
+                     #:date "2012"))
  10
+@(define b (make-bib #:title "Diss 2"
  11
+                     #:is-book? #t
  12
+                     #:location (dissertation-location #:institution "NEU")
  13
+                     #:author (authors (author-name "Ayo" "Shucks"))
  14
+                     #:date "2012"))
  15
+Order matters. Must sort by last names.
  16
+@cite[b]
  17
+@cite[a]
  18
+
  19
+@(gen)
7  collects/tests/scribble/docs/autobib-order.txt
... ...
@@ -0,0 +1,7 @@
  1
+Order matters. Must sort by last names.  (Shucks 2012)  (Peep and Gamgee
  2
+2012)
  3
+
  4
+Bibliography
  5
+
  6
+Little Bo Peep and Samwise Gamgee. Diss 1. PhD dissertation, NEU, 2012.
  7
+Ayo Shucks. Diss 2. PhD dissertation, NEU, 2012.                       
6  collects/tests/scribble/docs/autobib.txt
@@ -10,8 +10,8 @@ al. 2010, part II)  (Felleisen et al. 2010)
10 10
 Bibliography
11 11
 
12 12
 And no date. Look ma, no authors.                                     
13  
-Dorai Sitaram. Programming in Schelog. 1993.                          
14  
-http://www.ccs.neu.edu/~dorai/schelog/schelog.html                    
15  
-Look ma, no authors.                                                  
16 13
 Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics
17 14
 Engineering with PLT Redex. MIT Press, 2010.                          
  15
+Look ma, no authors.                                                  
  16
+Dorai Sitaram. Programming in Schelog. 1993.                          
  17
+http://www.ccs.neu.edu/~dorai/schelog/schelog.html                    

0 notes on commit 3caf0ac

Please sign in to comment.
Something went wrong with that request. Please try again.