# Biblatex reference sorting in same-first author, different-year entries

I'm using the biblatex bibliography package and I need the references to be sorted first by name, and references with the same first author to be sorted then by ascending year. In my preamble, the biblatex package is set like this:

\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[autostyle=true]{csquotes}

\usepackage[backend=biber,style=authoryear,natbib=true,sorting=nyt]{biblatex}

\begin{document}

Text \citep{Jinek2012}, and more text \citep{Jinek2013}.

\printbibliography[title=References]

\end{document}


While it may follow the nyt sorting scheme in some cases, it's overriden in others. In my library.bib, two of the problematic entries look like this:

@article{Jinek2013,
author = {Jinek, M. and Cheng, A. and Lin, S. and Ma, E. and Doudna, J. and
East, A.},
journal = {eLIFE},
title = {{RNA-programmed genome editing in human cells}},
volume = {2},
year = {2013}
}

@article{Jinek2012,
author = {Jinek, M. and Chylinski, K. and Fonfara, I. and Hauer, M. and
Doudna, J. and Charpentier, E.},
number = {6096},
pages = {816--821},
title = {{A programmable dual-RNA-guided DNA endonuclease in adaptive
bacterial immunity}},
volume = {337},
year = {2012}
}


Yet the result is:

However, this problem does not seem to apply for all same-first author, different-year articles, like these ones:

Is there any way I could force all same-first author, different-year articles to be sorted ascendingly by year after author sorting?

• Welcome to TeX.SX! By default biblatex sorts by all authors not just the first author, so what you see is kind of expected. Jun 4, 2018 at 16:30
• style=authoryear,citestyle=authoryear, is equivalent to style=authoryear and the style sets sorting=nyt automatically, so there is no need to specify it. Jun 4, 2018 at 16:30

biblatex sorts by all authors and not just the first and so the sorting is expected.

You can restrict sorting to the first author by extracting it with RegExp and writing it to sortname.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

%\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Jinek2013,
author = {Jinek, M. and Cheng, A. and Lin, S. and Ma, E. and Doudna, J. and
East, A.},
doi = {10.7554/eLife.00471.001},
journal = {eLIFE},
title = {{RNA-programmed genome editing in human cells}},
url =
{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3557905/pdf/elife00471.pdf
http://elife.elifesciences.org/content/2/e00471},
volume = {2},
year = {2013}
}
@article{Jinek2012,
author = {Jinek, M. and Chylinski, K. and Fonfara, I. and Hauer, M. and
Doudna, J. and Charpentier, E.},
doi = {10.1126/science.1225829},
isbn = {6212011575},
issn = {10959203},
journal = {Science},
number = {6096},
pages = {816--821},
title = {{A programmable dual-RNA-guided DNA endonuclease in adaptive
bacterial immunity}},
volume = {337},
year = {2012}
}
\end{filecontents}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=author, match=\regexp{(.*?)\s+and\s+}]
\step[fieldset=sortname, fieldvalue={\$1}]
}
}
}

\begin{document}
\cite{sigfridsson,Jinek2013,Jinek2012}
\printbibliography
\end{document}


• You just solved a problem from my todo-list before I even started looking for a solution! Jun 4, 2018 at 16:56
• @samcarter I'm wondering if there should be a 'proper' interface for that... Jun 4, 2018 at 17:58
• A proper interface would be very useful! This question comes up regularly on this site. Also while in this example the sorting is still understandable it gets really confusing if the difference in authors is hidden in et al. Jun 4, 2018 at 18:12
• @samcarter github.com/plk/biblatex/issues/755 Feel free to add comments on the usefulness (personal experience/preference or style guides that expect this). Jun 4, 2018 at 18:19