Another approach is along the lines you tried:
* Have the filenames and names in a map (key/value). * Take the key set and from it construct a sorted set * Go through the sorted set with a for loop and pick out the associated name.
Note that there is no array used at any point - that is making things more complicated.
Either way (this or KevinWorkman's) you will have to try things out and post some code so we can see exactly where you are stuck. And probably do a bit of reading. The various collections available are described well in Oracle's
Tutorial.