# Ordering items in index

An unexpected (to me!) index ordering in memoir. Here's a MWE.

\documentclass[11pt]{memoir}
\usepackage{makeidx}
\makeindex

\begin{document}

Aristotle \index{Aristotle}
(CP)      \index{:@(CP)}
$\to$     \index{0@$\to$}

\printindex
\end{document}


Since : comes in ascii between0 and A I would expect the index to be ordered

->, 1

(CP), 1

Aristotle, 1


But I get the unwanted

(CP), 1

->, 1

Aristotle, 1


Query: how to force what I want -- index listing symbols first (gap) list of rules of inference (gap) main alphabetic sequence.

• MakeIndex sorts symbols before numbers, then alphabetic strings. – egreg Sep 28 '19 at 16:11
• That doesn't give me quite what I want, as I need to use the "sortkey@" trick to get two blocks of entries into a bespoke order, before the main alphabetic ordering. I was wondering why sortkeys nnn came AFTER sortkeys :nnn when I'd expect the other way about given the ascii codes ... – Peter Smith Sep 28 '19 at 16:18
• :123 starts with a symbol. – egreg Sep 28 '19 at 16:20
• Ooops, sorry, I see what you mean! (Mmmmm, this is annoying .... !) – Peter Smith Sep 28 '19 at 16:27

Here's an extract from a very good manual on MakeIndex (texdoc ind)

What this doesn't say explicitly is that the sorting is

1. Symbols
2. Numbers
3. Strings

This explains your problem: \index{:@(CP)} will be sorted before \index{0@$\to$}, because the former entry is classified as a symbol. However, you can make a symbol for the latter entry by using \index{:0@$\to$}.

\documentclass[11pt]{memoir}
\usepackage{makeidx}
\makeindex

\begin{document}

Aristotle\index{Aristotle}
(CP)\index{::@(CP)}
$\to$\index{:0@$\to$}

\printindex

\end{document}