My
selectMap() method returns a TreeMap. I've confirmed that the keys are being placed into the TreeMap *in order* (not that that should matter). When I then retrieve the keySet and try to iterate over them, I find that their "natural order" seems to be wacky.
Starting at the bottom, read the numbers from right to left. (imagine you're reading them in a mirror)
01
11
1
2
21
etc...
The same thing happens when I try to get values() to get a Collection view. From the API:
But in fact, it's in the same order as shown above (only the output is the 'value' part of the TreeMap and not the key)
What is going on? Is the "natural order" of Strings (as implemented by
String's default Comparator) like this?
I think not, but what else could be happening?
[ April 05, 2003: Message edited by: Mike Curwen ]