I'm writing my own style and for most entry types the type
field must be printed after the title, but for some entries it must be printed before. So for some entry types I need the type
field to be sorted before the title
field, and for some I need it to be sorted after. Is there a way to do that?
MWE
\begin{filecontents}{\jobname.bib}
@book{abook,
author = {Alfred A.},
title = {A Book},
type = {B Type}}
@book{anotherbook,
author = {Alfred A.},
title = {Another Book},
type = {A Type}}
@article{anarticle,
author = {Alfred A.},
title = {An Article},
type = {C Type}}
\end{filecontents}
\documentclass{article}
\usepackage[backend=biber, bibstyle=standard]{biblatex}
\addbibresource{\jobname.bib}
\DeclareBibliographyDriver{book}{
\printnames{author}
\newunit
\printfield{title}
\newunit
\printfield{type}
}
\DeclareBibliographyDriver{article}{
\printnames{author}
\newunit
\printfield{type}
\newunit
\printfield{title}
}
\DeclareSortingScheme{nty}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{sorttitle}
\field{title}
\field{subtitle}
}
\sort{
%\field{type}
\field{sorttitle}
\field{title}
\field{subtitle}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{0000}
}
}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
This is what I get:
Since it's sorted by title
before type
, "An Article" comes before "Another Book", when it should actually come last, since it's type
starts with a "C".
Now if I uncomment that row that says \field{type}
I get this:
Since it's sorted by type
before title
, "Another Book" comes before "A Book", when the opposite should be true.
This answer suggests using the sortkey
field, but in my case this won't work, since the author always comes first.