Following my previous question, for this MWE,
\documentclass{article}
\usepackage[hidelinks,colorlinks=false]{hyperref}
\usepackage{lipsum}
\setlength\marginparwidth{0.8\dimexpr(\paperwidth - \textwidth)/2\relax}
\usepackage[textwidth=\marginparwidth]{todonotes}
\usepackage{etoolbox}
\makeatletter
\newcommand\@todonotes@owner{default}
\define@key{todonotes}%
{owner}{\def\@todonotes@owner{#1}}
\newtoggle{ownerdefault}
\newtoggle{ownerB}
\newcommand\stR[2]{% 1st reviewer comment
\todo[%
owner=default,
author=1st Reviewer,noline,caption={#1 Comment},color=blue!20%
]%
{#1 Comment}{\color{blue}{\bfseries#2}}}
\newcommand\ndR[2]{% 2nd reviewer comment
\todo[%
owner=B,
author=2nd Reviewer,noline,caption={#1 Comment},color=red!50!white%
]%
{#1 Comment}{\color{red}{\bfseries#2}}}
\renewcommand{\@todonotes@addElementToListOfTodos}{%
\if@todonotes@colorinlistoftodos%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\protect\fcolorbox{\@todonotes@currentbordercolor}%
{\@todonotes@currentbackgroundcolor}%
{\protect\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
\ \@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\else%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\fi}%
\makeatother
\begin{document}
\toggletrue{ownerdefault}
\section*{Reviewer \#1 Comments}
\InputIfFileExists{\jobname.tdo}{}
\toggletrue{ownerB}
\togglefalse{ownerdefault}
\section*{Reviewer \#2 Comments}
\InputIfFileExists{\jobname.tdo}{}
\togglefalse{ownerB}
\makeatletter \@starttoc{tdo}\makeatother % to trigger the creation of the list
\section{Section}
Text \stR{\#2}{2nd comment of the 1st reviewer} another text\vspace{\baselineskip}
\lipsum[1-2]\vspace{\baselineskip}
Text \ndR{\#3b}{3rd comment of the 2nd reviewer} another text.\vspace{\baselineskip}
\lipsum[1-2]\vspace{\baselineskip}
Some text \stR{\#1}{1st comment of the 1st reviewer} continue text.\vspace{\baselineskip}
\lipsum[1-2]\vspace{\baselineskip}
Text \ndR{\#3a}{1st comment of the 2nd reviewer} another text.\vspace{\baselineskip}
\end{document}
I need to know how to alphanumerically sort the entries of listoftodos according to the first argument the custom todo commands?
For example, I need the first list entries to be sorted like:
#1 Comment
#2 Comment
and the second list entries to be sorted like:
#3a Comment
#3b Comment

