While I'm not sure of the algorithm -Is it numerically largest first? If so, are you sure that makes sense for all possible addresses?-, using a Comparator with a List can accomplish that. If you haven't used Comparators before, read http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
1. Welcome to JavaRanch.
2. Please DontWriteLongLines (←click). I've broken yours up as best I can, but before you post again, please read the UseCodeTags page thoroughly.
3. In general, we don't like people to simply post solutions (I assume that was your intent). Far better to help OP, but let him/her work it out for themselves.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:3. In general, we don't like people to simply post solutions (I assume that was your intent). Far better to help OP, but let him/her work it out for themselves.
The OP had posted their own solution and it was almost three years ago, so it's probably not a problem here.