# glossaries special sorting for one glossary

In my document I use several glossaries, one of which is for the nomenclature. I have some special wishes for the sorting of this glossary. The easist way to achieve what I want is if I could give the sort=def option for only one glossary, but as fasr as I can tell this is only available as a package option.

Therefore I think I might have to write my own rules. Since I have no experience with xindy what soever I would like to know if the following rules are a good starting point.

What I want:

1. a term X prefixed with # comes right after X
2. if a term X is followed by an underline it comes right after X and before #X

Example

 X
#X
X_index
#X_index
Xindex
#Xindex


What I think might be reasonable rules after looking here:

(merge-rule "<startOfLine>\#"(.*)<endOfLine>" "\1~e")
(merge-rule "<startOfLine>(.*[^~e])<endOfLine>" "\1~b")
(merge-rule "_" "~b")


I am not sure how to force a match for the entire line with the first rule. I am not sure either how to formulate the does not end with last character bit in the second rule. The second rule aims to prevent \#X ending up behind Xa.

Furthermore I looked at samplexdy.tex from the glosaries package (docfolder/samples) and noted that the according xindy file looked huge, so any pointers on where I insert my rules or what I actually need would be apreciated. And how do I teach glossaries that I want to use the modified xindy file only for one glossary out of several?

-

As from glossaries version 4.04, it's now possible to use different sort methods, but only if you use the \makenoidxglossaries option which uses TeX to perform the sorting:

\documentclass{article}

\usepackage[nopostdot,nogroupskip]{glossaries}

\newglossary{nomen}{}{}{Nomenclature}

\makenoidxglossaries

% main glossary

\newglossaryentry{goose}{name={goose},description={}}
\newglossaryentry{zebra}{name={zebra},description={}}
\newglossaryentry{duck}{name={duck},description={}}
\newglossaryentry{aardvark}{name={aardvark},description={}}

% nomenclature
\newglossaryentry{X}{type=nomen,name={X},description={}}
\newglossaryentry{hashX}{type=nomen,name={\#X},description={}}
\newglossaryentry{X-index}{type=nomen,name={X\_index},description={}}
\newglossaryentry{hashX-index}{type=nomen,name={\#X\_index},description={}}
\newglossaryentry{Xindex}{type=nomen,name={Xindex},description={}}
\newglossaryentry{hashXindex}{type=nomen,name={\#Xindex},description={}}

\begin{document}
Test document.