I have been trying to find a package or a method to sort lists of names in an easy manner in TeX/LaTeX. I have tried some of the routines in the xfor package, as well as looked at some of the new macros in LaTeX3 but was not very successful with either of them.
I have come with the idea of using the MakeIndex program to sort and categorize. It is available with every distribution and the LaTeX class is very short and easily hackable being approximately 36 lines long (including the glossary macros that I can eliminate) and a few more definitions for styling in the basic book or article class.
Here is a minimal example that sorts a list of names by profession (category).
\documentclass[11pt]{article}
\usepackage{makeidx}
\def\addName#1#2{\index{Name!#1}\index{#2!#1}}
\makeindex
\begin{document}
\renewcommand{\indexname}{Famous and Infamous Sorted People}
\addName{Leslie Lamport}{Computer Scientist}
\addName{Donald Knuth}{Computer Scientist}
\addName{Tim Berners Lee}{Computer Scientist}
\addName{Brian Kernighan}{Computer Scientist}
\addName{Noam Chomsky}{Linguist}
\addName{Yiannis Lazarides}{Lifelong Trainee \protect\TeX nician}
\addName{Leonard Euler}{Mathematician}
\addName{Carl Friendrich Gauss}{Mathematician}
\addName{August Ferdinard M\"{o}bius}{Mathematician}
%% Importing the .ind file rather than use \printindex
%% so we do not need to redefine the command
%%
\input{indextest.ind}
\begin{verbatim}
\begin{theindex}
\item Lifelong Trainee \TeX nician
\subitem Yiannis Lazarides, 1
\item Linguist
\subitem Noam Chomsky, 1
\end{theindex}
\end{verbatim}
\end{document}
Is this a good idea? Are there any packages devoted to alphanumeric sorting? I know it can easily be done with an external script, but I am looking for a TeX/LaTeX solution. Do you think it is a good approach?
datagidx
(part of thedatatool
bundle). However, as it uses TeX to do the sorting, it's a lot slower than usingmakeindex
.l3sort
since that time. This allows sorting various things.