[Tex/LaTex] How to sort in biblatex by name, year, order of appearance

biblatexsorting

I am using biblatex with the following settings:

  • backend=biber
  • style=authoryear
  • citestyle=authoryear-comp
  • sorting=nyt

This works as expected, but I find the sorting=nyt to be suboptimal. I would rather sort by name, year, and then order of appearance in the text.

Why? The title of the paper has little relevance for the reader, but it still determines the order of disambiguation marks "a", "b", etc when there are multiple citations in a year. For example, imagine the two following publications by John Doe, both published in year 2017, with the titles

  • "Emerging evidence for x"
  • "Another piece of evidence for x"

Now, even if I cite the first paper (Emerging evidence) first and the second paper last (Another piece of evidence), the first will be cited as Doe (2017b) and the second will be Doe (2017a). Looks stupid to me.

What is the best way to have biblatex sort the citations in order name, year, order of appearance?

Best Answer

Look in the file biblatex.def to find definitions of the different sortings. Based on a combination of the sorting=none sorting and sorting=nyt I came up with the following which I call sorting=nyc (c for \citeorder).

\DeclareSortingScheme{nyc}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{\citeorder}
}

Just put this snippet after the \usepackage[sorting=nyc,...]{biblatex} command. Don't forget to specify sorting=nyc in the biblatex options.

Edit: presort and sortkey included in the beginning as suggested and explained by @moewe in two comments below.

Edit 2: Bugfixed code to really give order nyc. Thanks to @moewe for alerting me to the mistake.