I'm searching for a way to edit/re-order the entries in the .bib file to match the ordering defined for the bibliography. There are several questions here about ordering the bibliography, but I haven't found anything regarding ordering the .bib file itself...perhaps because it isn't possible! For instance, Sorting bibliography according to the order in .bib file is the opposite of what I'm looking for. I want to sort the .bib file according to the order in the bibliography.

The reason is because I have several .bib files organized by topic, each topic file organized by when I read the source. It would save me quite a bit of time to have the entries organized so that, for instance, I could delete an entire stretch of one author's sources instead of searching for them one by one.



    author          = {Mike Man},
    title           = {Title},
    year            = {2016},
    publisher       = {Books},

    author          = {Bill Ban},
    title           = {Name},
    year            = {2009},
    publisher       = {Publisher},

    author          = {Bill Ban},
    title           = {Something},
    year            = {2014},
    publisher       = {Somewhere},







Ideally there could be a way to reorder bib.bib such that it matches the defined ordering in the bibliography (thus, authordate,sorting=nyt). In this case, the intended ordering should be cde, abc, bcd.


This is possible with biber's tool mode. Suppose your .bib is "test.bib" and you have the following in "test.conf" (this is just the config file version of the "nyt" sorting scheme - see the biblatex/biber PDF docs about this).

  <!-- nyt SORTING -->
    <sort order="1">
      <sortitem order="1">presort</sortitem>
    <sort order="2" final="1">
      <sortitem order="1">sortkey</sortitem>
    <sort order="3">
      <sortitem order="1">sortname</sortitem>
      <sortitem order="2">author</sortitem>
      <sortitem order="3">editor</sortitem>
      <sortitem order="4">translator</sortitem>
      <sortitem order="5">sorttitle</sortitem>
      <sortitem order="6">title</sortitem>
    <sort order="4">
      <sortitem order="1">sortyear</sortitem>
      <sortitem order="2">year</sortitem>
    <sort order="5">
      <sortitem order="1">sorttitle</sortitem>
      <sortitem order="2">title</sortitem>
    <sort order="6">
      <sortitem order="1">volume</sortitem>
      <sortitem order="2">0</sortitem>

Then simply run this command:

biber --tool --configfile=test.conf test.bib

and your sorted .bib will be in test_bibertool.bib.

biber uses a default config file in tool mode which you can find by running:

biber --tool-config

you can then copy this file and edit it to your needs. You can do many things to your .bib files with tool mode such as reformatting, sorting, changing the data using sourcemaps, materialising inheritance rules etc. See the biber PDF documentation.

The biber PDF manual (currently section 3.1.7) has details of the format of the sorting specification accepted in the config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.