I work with LaTeX and do versioning with Git. For bibliography management I use Mendeley.
The problem is that each time Mendeley synchronizes it's .bib
exports,
they are in different order, what makes bibliography versioning much harder.
My idea is to sort BibTex entries in .bib
file, each time before commit.
Could you help me, how to do this in smart (short&sweet) way ? 🙂
P.S. I can run this routine manually. I do not need git integration. I just want program/script to sort .bib
file.
Best Answer
How about
bibsort
?It's a shell script wrapping
nawk
(andtr
,sort
andgrep
) 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...?