I'm attempting to automate Werner's answer to my question here.
In short, in order to sort the Norwegian letters Æ Ø Å (they come at the end of the regular Latin alphabet) correctly dtlsort needs some help. This means replacing æ with za, ø with zb, etc.
I tried doing this with xstring's \StrSubstitute command, but it can only replace one string at a time, and doesn't seem to like being nested.
One single pass works in PDFLaTeX.
This MWE should output zbzazc.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{datatool,xparse}
\usepackage{xstring}
\NewDocumentCommand{\norskletterssub}{m}{%
\def\strA{\StrSubstitute{#1}{æ}{za}}
\def\strB{\StrSubstitute{\strA}{ø}{zb}}
\def\strC{\StrSubstitute{\strB}{å}{zc}}
\strC
}
\begin{document}
\norskletterssub{øæå}
\end{document}
I need to run multiple passes because there's obviously no guarantee there's only one of each letter.
Additionally, there aren't any capital letters that need to be checked for.
What's the best way to do this?

