You can use a TreeMap. It has has an ordering to its keys.
I
am a little worried about all you guys understanding what collating sequences are.
There are 2 options if you don't care what the code is.
1. Create a TreeMap<Integer, String> to hold your key/value pairs and increment an integer counter. Since the natural ordering of integers places 9 before 10, unlike text-based ordering where "1", "10", "11", "2",,, "9" is the rule, that's sufficient.
2. Alternatively, look at the
Java formatting resources such as MessageFormat. You can build character strings in the form "001", "002", ... "009", "010", and they, too will collate properly, thanks to the leading zeroes.