How to sort (by whatever key) BibTex entries in `.bib` file?
How about bibsort
?
NAME
bibsort - sort a BibTeX bibliography file
SYNOPSIS
bibsort [optional sort(1) switches] < infile >outfile
DESCRIPTION
bibsort filters a BibTeX bibliography, or bibliography frag-
ment, on its standard input, printing on standard output a
sorted bibliography.
It's a shell script wrapping nawk
(and tr
, sort
and grep
) and includes two warnings you might have to pay attention to (see the source).
(Edit There're also a lot of bibtex-related Perl modules...)
Edit2 I just recognized you'd like to sort for any key, while bibsort
apparently sorts by the bibtex tags only -- but maybe its source (it's not too long) is still helpful...?
You can use bibtool
(-s
option - sort according to the reference key) with the git post-commit hook.
The reference manager jabref
seems to have such an option in the preferences (see Sort order section in File page). It also has many interesting features: