biblatex,bibtex,sorting – Troubleshooting \DeclareSortingTemplate Issues in BibLaTeX

biblatexbibtexsorting

In the following MWE, I expect reference "B" to appear before "A" in the reference list, because sortyear should take priority over year. But I can't get that to happen after much tinkering… I've read this and this questions and the corresponding section of biblatex manual without much help.

\documentclass{article}
\usepackage[
  backend=bibtex,
  defernumbers=true,
  sorting=xxx,
]{biblatex}
\begin{filecontents}[overwrite]{mwe.bib}
  @article{A,
    title = {A},
    year = {1111},
    sortyear = {2222}
  }
  @article{B,
    title = {B},
    year = {2222},
    sortyear = {1111}
  }
\end{filecontents}
\addbibresource{mwe}\nocite{*}
\DeclareSortingTemplate{xxx}{
  \sort{
    \field{sortyear}
    \field{year}
  }
}
\begin{document}
  \printbibliography[resetnumbers=true]
\end{document}

Best Answer

As discussed in the comments, with backend=bibtex you can only use a restricted list of sorting schemes (none, nty, nyt, nyvt, anyt, anyvt, ynt, ydnt, debug) and \DeclareSortingTemplate is not available at all with BibTeX.

You will need to use Biber with your document. (Which is a good idea anyway since many of biblatex's advanced features require Biber. The documentation used to explain which bits were Biber-only, but a few years ago it was decided to make BibTeX a "legacy backend" and just assume that the average user uses Biber.)

https://github.com/plk/biblatex/commit/0c21cd8c142d1a2f0c2d1e4810890388fa82551e will give a warning in case unsupported sorting templates are used with BibTeX.