# [Tex/LaTex] Sorting bibliography in chronological order [natbib]

bibtex

NOT using biblatex, I want my bibliography sorted in chronological order.

Why do I want that? Mainly because I think that way the bibliography not only serve as a "repository" for the references, but it also shows the progression of the literature on the topic.

I have searched the web, but mainly ended up with in-text sorting only, or not working modification of the bibtex style bst file.

I came up with a small set of modifications for a bst file. I only tested it with author-year style, francaissc.bst.

Basically, the presort function must be altered.

Without entering in too much details about the bst files, there is one thing to understand for making those modifications: the .sort are functions, that must be defined, for example author.editor.sort is most likely already defined in an author-year style.

Hence, first thing to do is to add those functions:

FUNCTION {year.author.sort}
{ year empty${ author empty$
{ key empty${ "to sort, need year, author, or key in " cite$ * warning$"" } { key sortify } if$
}
{ author sort.format.names }
if$} { year sort.format.names } if$
}
FUNCTION {year.sort}
{ year empty${ key empty$
{ "to sort, need year or key in " cite$* warning$
""
}
{ key sortify }
if$} { year sort.format.names } if$
}


They are very simple because they rely on stuff already defined in there, mostly the sort.format.names function.

Then, you must modify the presort function itself. Basically, change author to year, but I let be the judge of what you actually want to change. In my case I now have (a commented line is the previous content, with the new one next line):

FUNCTION {presort}
{ calc.label
label sortify
"    "
*
type$"book" = type$ "inbook" =
or
%    'author.editor.sort
'year.author.sort
{ type$"proceedings" = % 'editor.sort % 'author.sort 'author.sort 'year.sort if$
}
if$#1 entry.max$ substring$'sort.label := sort.label * " " * % title field.or.null year field.or.null sort.format.title * #1 entry.max$ substring$'sort.key$ :=
}


And for an added bonus, with the 'sort' option of the natbib package, the in-text references are now also ordered chronologically, because the main bibliography is.