In that case, how about using Collections.reverseOrder()? That will give you a Comparator that sorts in reverse (natural) order. So once you've put them in an array or List, sort it with that then iterate as usual.
Whether that's simpler than what you're doing now is up to you!
Joined: Jul 26, 2011
If this is what you mean.
then I prefer it than the for (int i=keys.length-1;i>-1;i--)
because I don't have to be remember/careful about the numeric index boundary - ArrayIndexOutOfBoundsException.