This issue is related to this other issue.
In my custom entrytype I use two alternate fields: author (names of persons) and usera (names of institutions).
In any pre-existing sorting template (e.g. nty, anyvt, etc.), the usera field must be handled as if it were an author/editor field.
So, without having/wanting to create a custom sorting template, I thought of using the sortname field, through sourcemapping.
% !TEX encoding = UTF-8 Unicode
% !TEX program = lualatex
% !BIB program = biber
\begin{filecontents}{\jobname.bib}
@customa{a,
author = {Smith, John},
title = {Title},
date = {2000},
}
@customa{b,
usera = {M M},
title = {Title},
date = {3000},
}
@customa{c,
usera = {A Z},
title = {Title},
date = {1000},
}
@customa{d,
author = {Doe, Jane},
title = {Title},
date = {4000},
}
\end{filecontents}
\documentclass{article}
\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps{
\map{
\pertype{customa}
\step[fieldsource=usera, match=\regexp{\A(.*)\Z}, final]
\step[fieldset=sortname, fieldvalue={{$1}}]
}
}
}
\DeclareBibliographyDriver{customa}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{usera}%
\printnames{author}%
\newunit\newblock
\usebibmacro{title}%
\newunit\newblock
\printdate%
\usebibmacro{finentry}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
The sourcemapping code should be equivalent to the following .bib file:
@customa{a,
author = {Smith, John},
title = {Title},
date = {2000},
}
@customa{b,
usera = {M M},
title = {Title},
date = {3000},
sortname = {{M M}},
}
@customa{c,
usera = {A Z},
title = {Title},
date = {1000},
sortname = {{A Z}},
}
@customa{d,
author = {Doe, Jane},
title = {Title},
date = {4000},
}
but the ordering is not as expected.
