TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to sort an alphanumeric list

For example, I have the following code:

  \item Rabbit
  \item Apple
  \item Serpent

Is there a way to add something to this and get a sorted, numbered list as output?

share|improve this question

marked as duplicate by yo', Thorsten, cmhughes, Alan Munn, lockstep Apr 23 '12 at 15:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Related question: tex.stackexchange.com/questions/6988/… There the issue is solved in multiple different ways. – Vairis Apr 23 '12 at 9:28
up vote 3 down vote accepted

You can use a comma delimited list and then sort it. Here is a MWE.




%% adding the data now

   \thecnt\space \next\\

You can format the output within the \@for loop.

share|improve this answer
It looks good. But it prints an empty line at the end ("5") for me. And will it be possible to make several sorted lists in one document? – Rogach Apr 23 '12 at 10:31
@Rogach Thanks, will add a more complete solution late in the evening. Anything is possible in TeX. – Yiannis Lazarides Apr 23 '12 at 11:04
Thank you very much! – Rogach Apr 23 '12 at 11:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.