When I index a molecular formula, I use the syntax \index{C8H12O4} and \index{C10H16O5}. The resulting output will have C10 before the C8 compound. What I understand is: in the second entry, C is followed by 1, whereas in the first case, C is followed by 8. 1 is less than 8, hence C10 comes before C8.
The question is how to reorder so that C with lower number comes first and then the other. In the above case, C8 first, followed by C10.
A related question is: the CAS numbers “100-51-7” will appear before “88-45-6”. How to make it work the other way round?
Here is my MWE
\documentclass[a4paper,10pt]{book}
\usepackage{imakeidx} % as i have multiple indexing
\makeindex % as i have multiple indexing
\begin{document}
The illustrative example to show the problem I'm facing with indexing. C8H12O4\index{C8H12O4} and C10H16O5\index{C10H16O5} are interesting compounds. The resulting output will have C10 above the C8 compound.
Also checked for CAS numbers: 100-51-7\index{100-51-7} and 88-45-6\index{88-45-6} has to be indexed in the reverse order. First 88-45-6, then 100-51-7.
\printindex
\end{document}
\documentclassand the appropriate packages so that those trying to help don't have to recreate it. This will also serve as a test case and ensure that the solution actually works for you. That way those trying to help can focus on solution as opposed to setting up the problem test case. – Peter Grill Mar 13 '12 at 3:45