Troy's answer needs a couple of patches for this. The first is already given in a comment, \two@digits adds a zero to the start of any single-digit numbers, going over 100 we now need a three-digit version of each number so define and use
\def\three@digits#1{\ifnum#1<100 0\ifnum#1<10 0\fi\fi\number#1}
The second part is probably a mistake in the linked answer, the optional argument is omitted in favour of the counter, with \string\nomenclatureentry{#1\nom@verb in the package becoming \string\nomenclatureentry{\the@nomcount\nom@verb in the answer. However, I don't see any reason not to first sort by the prefix and then by order of appearance (if you just want order of appearance and a single list, just don't use the prefix). This would call for \string\nomenclatureentry{#1\the@nomcount\nom@verb.
So relative to Troy's answer we need a couple of small changes in the \makeatletter/\makeatother block
\makeatletter
\def\three@digits#1{\ifnum#1<100 0\ifnum#1<10 0\fi\fi\number#1}
\iftoggle{nomsort}{%
\let\old@@@nomenclature=@@@nomenclature
\newcounter{@nomcount} \setcounter{@nomcount}{0}%
\renewcommand\the@nomcount{\three@digits{\value{@nomcount}}}% Ensure 100>001,010 etc
\def@@@nomenclature[#1]#2#3{% Taken from package documentation
\addtocounter{@nomcount}{1}%
\def@tempa{#2}\def@tempb{#3}%
\protected@write@nomenclaturefile{}%
{\string\nomenclatureentry{#1\the@nomcount\nom@verb@tempa @[{\nom@verb@tempa}]% Write prefix and then order
\begingroup\nom@verb@tempb\protect\nomeqref{\theequation}%
|nompageref}{\thepage}}%
\endgroup
@esphack}%
}{}
\makeatother
which we can see works with your multiple lists and over 100 nomenclature instances.
\documentclass{article}
\usepackage{etoolbox}
\usepackage{nomencl}
\makenomenclature
\providetoggle{nomsort}
\settoggle{nomsort}{true} % true = sort by use, false = sort as usual
\makeatletter
\def\three@digits#1{\ifnum#1<100 0\ifnum#1<10 0\fi\fi\number#1}
\iftoggle{nomsort}{%
\let\old@@@nomenclature=@@@nomenclature
\newcounter{@nomcount} \setcounter{@nomcount}{0}%
\renewcommand\the@nomcount{\three@digits{\value{@nomcount}}}% Ensure 10>01
\def@@@nomenclature[#1]#2#3{% Taken from package documentation
\addtocounter{@nomcount}{1}%
\def@tempa{#2}\def@tempb{#3}%
\protected@write@nomenclaturefile{}%
{\string\nomenclatureentry{#1\the@nomcount\nom@verb@tempa @[{\nom@verb@tempa}]%
\begingroup\nom@verb@tempb\protect\nomeqref{\theequation}%
|nompageref}{\thepage}}%
\endgroup
@esphack}%
}{}
\makeatother
\newif\iffirstglossary\firstglossarytrue
%% This removes the main title:
\renewcommand{\nomname}{}
%% this modifies item separation:
\setlength{\nomitemsep}{8pt}
%% this part defines the groups:
%----------------------------------------------
\renewcommand\nomgroup[1]{%
\iffirstglossary
\firstglossaryfalse
\else
\clearpage
\fi
\item[\Large\bfseries
\ifstrequal{#1}{N}{List of Symbols}{%
\ifstrequal{#1}{O}{List of Operators}{%
\ifstrequal{#1}{A}{List of Abbreviations}{}}}%
]\vspace{10pt}} % this is to add vertical space between the groups.
\begin{document}
\ExplSyntaxOn
\str_map_inline:nn {kjihgfedcba}{
\str_map_inline:nn {kjihgfedcba}{
\nomenclature[N]{$#1##1$}{#1##1}
\nomenclature[O]{$#1##1$}{#1##1}
}}
\ExplSyntaxOff
\nomenclature{$j$}{Appears first}
\nomenclature{$i$}{Appears second}
\nomenclature{$h$}{Appears third}
\nomenclature{$g$}{Appears fourth}
\nomenclature{$f$}{Appears fifth}
\nomenclature{$e$}{Appears sixth}
\nomenclature{$d$}{Appears seventh}
\nomenclature{$c$}{Appears eighth}
\nomenclature{$b$}{Appears ninth}
\nomenclature{$a$}{Appears tenth~(last)}
\printnomenclature
Abbreviations appear as in \verb|https://tex.stackexchange.com/a/383460|.
Symbols and Operators appear separately through use of the optional prefix, both defined in order $kk$, $kj$, \ldots, $ka$, $jk$, \ldots, $aa$.
\end{document}
nomgroupdefinition and anything else you're doing that might affect the spacing. You're probably pushing the limits ofnomenclthough and might be better off adoptingglossaries. – Dai Bowen Apr 19 '23 at 18:20