# Sorting citations using \cites command in biblatex produces error

Sorting citations using \cites command in biblatex with Sorting citations using \cites command in biblatex worked fine but doesn't work anymore with TexLive 2016.

Error produced with the minimal example of the above link:
! Undefined control sequence.
<argument> \cbx@sortkeys

l.49 ...mpanion}{ctan}{markey}[10--11]{vangennep} \\


Its's not just a wrong error message by running first time biber. There is no output for the intended sorted \Cites and \cites commands.

Anybody knows how to adjust the code for new TexLive 2016?

• In which version did it work? With TL 2015 I get the same error as with 2016. – user36296 Jun 11 '16 at 10:54
• I guess it was with biblatex version pre-march 2016, however the proposed code should work with TeXLive 2016 or would need some changes. The problem stays the same: how can I sort multiple bib-entries with biblatex and biber and the cited comands? – Michael Jun 12 '16 at 13:30

I had the same problem and searched in the old and new biblatex.sty and related files. I found where the definition of

{\global\letcs{\cbx@sortkeys}
{blx@slists@\the\c@refsection @entry@\blx@sorting}}% Biber


in Audray's solution (Sorting citations using \cites command in biblatex) came from. This does not work with the actual biblatex, because some of the arguments used here are not defined anymore. I had to replace these lines with the definition found in the actual biblatex:

{\global\letcs{\cbx@sortkeys}
{blx@slist@centry@\the\c@refsection @\blx@refcontext@context}}% Biber


It is still not the cleanest solution using the deep internals of biblatex, but it woks for me ...

Here a MWE. It is a patch of the MWE in Audrey's brilliant answer (so the credits still belong to him):

\documentclass{article}
\usepackage[style=authortitle,sorting=ynt,sortcites]{biblatex}

\makeatletter
% original definition of \cites
\DeclareMultiCiteCommand{\cbx@cites}{\cite}{\multicitedelim}

% new definition
\DeclareMultiCiteCommand{\cites}[\cbx@cite@wrapper\cbx@cites]{\cbx@cite}{}

% first pass saves keys, prenotes, postnotes
\DeclareCiteCommand{\cbx@cite}
{\csxdef{prenote:\thefield{entrykey}}{\thefield{prenote}}}
{}
{\csxdef{postnote:\thefield{entrykey}}{\thefield{postnote}}}

% second pass outputs sorted citation list
\newrobustcmd{\cbx@cite@wrapper}[2]{%
\def\cbx@savekeys{}%
\def\cbx@citecall{#1}%
#2\cbx@sortkeysinit\cbx@citesort\cbx@citecall}

% internal list of saved keys => sorted argument list
\def\cbx@citesort{%
\def\do##1{%
\ifinlist{##1}{\cbx@savekeys}
{\protected@xappto\cbx@citecall{%
[\csuse{prenote:##1}][\csuse{postnote:##1}]{##1}}}
{}}%
\dolistloop{\cbx@sortkeys}}

% internal list of sorted entry keys [patched to the original answer, new biblatex!]
\def\cbx@sortkeysinit{%
\ifcsundef{blx@slist@centry@\the\c@refsection @\blx@refcontext@context}
{}
{\global\letcs{\cbx@sortkeys}{blx@slist@centry@\the\c@refsection @\blx@refcontext@context}}}
\def\cbx@sortkeys{}
\makeatother


• OK, I did some more digging, it should work perfectly if you replace the definition of \cbx@sortkeysinit by \def\cbx@sortkeysinit{% \ifcsdef{blx@slist@centry@\the\c@refsection @\blx@refcontext@context} {\global\letcs{\cbx@sortkeys}{blx@slist@centry@\the\c@refsection @\blx@refcontext@context}} {}} (mod line breaks). In version 3.5 this works for both biblatex and Biber from the first run without any errors. If you include that in your answer and write a full MWE I'd be more than happy to up-vote it. – moewe Sep 15 '16 at 12:38