I need to write a class that handles a Map<String, String[]>
, processing its keys according to their numeric order. To add insult to injury, some keys are not valid integers, and they should be processed at the end, in acceding lexicographic order.
For example, if the keys are:
["10", "2", "100", "duck", "black"]
They should by iterated at this order -
["2", "10", "100", "black", "duck"]
What's the most elegant way to do it in Java, other than iterating and try-catching NumberFormatException
? Obviously, I can not control the format of the given map.