# Problem with nodate and date sorting in author-date biblatex

I have problems (1) nodate, and as a result with (2) datesorting with biblatex 2.9a, Biber 1.8, pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)

(1) nodate I cannot get the bibliographic string nodate to appear. I get a blank instead. Because the date field is blank, it places the item first in sort order instead of last.

A minimum working example is provided by the original complainant about this issue in an early version at this link: Biblatex and entries with no date

I tried the minimum working example there said to be successful with Biber 1.6 but now with biber 1.8 I get:

Lennon, John. Peace on earth.
—. 1972. More peace on earth.


(1)-(2) I want the dated version first and "n.d." in the undated version. I tried using sortdate = {2099} to correct the sort order, but it does nothing. Setting year = {n.d.} in the bib file works, but is a hack.

## 2 Answers

In order for the nodate string to also appear in the bibliography, redefine date+extrayear like this

\renewbibmacro*{date+extrayear}{%
\printtext[parens]{%
\iffieldsequal{year}{\thefield{datelabelsource}year}
{\printdateextralabel}%
{\printfield{labelyear}%
\printfield{extrayear}}}}%


This solution works with mergedate=compact (the default) in authoryear (and authoryear-like bib styles). For other mergedate settings, you will have to apply a different modification, the pattern, however, is always the same: Get rid of the \iffieldundef{\thefield{datelabelsource}year} check and make sure that the second part of the code (the "else" statement) is executed (this can often be achieved by simply commenting out the \iffieldundef{\thefield{datelabelsource}year} line, since the "if" portion of the code is often an empty group and does nothing).

For the sorting, I would recommend

\DeclareSortingScheme{nyt}{
\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}
\literal{9999}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{0000}
}
}


This is just the standard definition with \literal{9999} added to the end of the "year" sorting block. So we make the year a 9999 for sorting, if it does not exist, of course this can be applied to other sorting schemes as well.

MWE

\documentclass{article}
\usepackage{csquotes,filecontents}
\usepackage[style=authoryear,dashed=false]{biblatex}
\begin{filecontents*}{\jobname.bib}
@BOOK{lennon,
AUTHOR = "John Lennon",
TITLE = "Peace on earth"}
@BOOK{lennon1972,
AUTHOR = "John Lennon",
TITLE = "More peace on earth",
YEAR = "1972"}
\end{filecontents*}
\addbibresource{\jobname.bib}

\DeclareSortingScheme{nyt}{
\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}
\literal{9999}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{0000}
}
}

\renewbibmacro*{date+extrayear}{%
\printtext[parens]{%
\iffieldsequal{year}{\thefield{datelabelsource}year}
{\printdateextralabel}%
{\printfield{labelyear}%
\printfield{extrayear}}}}%

\begin{document}
\textcites{lennon}{lennon1972}.
\printbibliography
\end{document}


You can use the sortkey field for this, see under 3.5 in the biblatex manual. E.g. add a

SORTKEY = "Z",


or similar to the respective entries of your .bib file.