For my Phd thesis, I'm using the glossaries package from Nicola Talbot to create multiple glossaries - including a list of court decisions that I've cited within the thesis.
In the mentioned list of court decisions, I want them to be sorted by the name of the court and the decision date (given format: DD.MM.YYYY). Therefore, I create a sort key using the xstring package (formatted "Court-YYYY-MM-DD") and pass it as sort key in the \newglossaryentry command (via my macro called \decision{key}{shortinfo}{longinfo}).
The sort keys in the below example are:
BGH-2000-12-08
BGH-2003-01-09
BGH-2010-10-05
I makeindex using the following bash script within my latex engine
for file in *-glo ; do
makeindex -t ${file%-glo}-glg -s $docname.ist -o ${file%-glo}-gls $file
done
Unfortunately, the printed decision glossary seems to ignore the sort keys. It seems that the decision entries are still being sorted by just using the glossary entry description.
The output of the below minimal example shows as
BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH.
BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH.
BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188.
instead of
BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH.
BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188.
BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH.
Minimal example:
\usepackage{xstring}
\usepackage[toc=true]{glossaries}
\newglossary[decision-glg]{decision}{decision-gls}{decision-glo}{Decisions}
\makeglossaries
% Macro to create sort key
\newcommand{\getCourt}[1]{\StrBefore[1]{#1}{,}}
\newcommand{\getYear}[1]{\StrBetween[2,2]{#1}{.}{,}}
\newcommand{\getMonth}[1]{\StrBetween[1,2]{#1}{.}{.}}
\newcommand{\getDay}[1]{\StrBetween[1,1]{#1}{vom }{.}}
\newcommand{\getsortstring}[1]{\getCourt{#1}-\getYear{#1}-\getMonth{#1}-\getDay{#1}}
\newcommand{\justprint}[1]{#1}
% Manipulate sorting
\let\courtdate\justprint
\renewcommand{\glsprestandardsort}[3]{%
\ifdefstring{#2}{decision}{%
\let\courtdate\getsortstring%
\edef#1{\expandafter\expandonce\expandafter{#1}}%
\let\courtdate\justprint%
\glsdosanitizesort%
}{%
\glsdosanitizesort%
}%
}
% Macro to add decisions as glossary entry: \decision{key}{shortinfo}{longinfo}
\newcommand{\decision}[3]{%
\newglossaryentry{#1}{type=decision, name={#2}, description={#3}, sort={\getsortstring{#3}}}%
}
% Create new style for the glossary
\newglossarystyle{decisionlist}{%
\renewenvironment{theglossary}{\begin{spacing}{1.5}}{\end{spacing}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossentry}[2]{%
\noindent% No left padding
\textbf{% Make bold
\StrBefore{\glossentrydesc{##1}}{,}% Insert court name
},% Add comma
\StrBehind{\glossentrydesc{##1}}{,}.% Insert decision info
\\}% Insert newline after entry
\renewcommand*{\subglossentry}[3]{}%
\renewcommand*{\glsgroupskip}{}%
}
% Add decisions as glossary entries using the above macro
\decision{BGH, V ZR 482/99}{BGHZ-Online, V ZR 482/99}{BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}
\decision{BGH, VII ZR 181/00}{BGH, NJW 2003, 1188}{BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188}
\decision{BGH, V ZR 228/09}{BGHZ-Online, V ZR 228/09}{BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH}
\begin{document}
\setglossarystyle{decisionlist}
\printglossary[type=decision]
I am citing all of the above decisions. Those are \gls{BGH, V ZR 482/99}, \gls{BGH, V ZR 228/09} and \gls{BGH, VII ZR 181/00}.
Since I'm trying for ages now, to sort out, why the entries are displayed in the wrong order despite me passing the sort keys, I'd be more than happy if someone could lead the way :)