Agree completely, thats why I pointed that lists have to be sorted. Since this seems to be followup to storing all file info, I assumed that no problem make lists sorted on its creation.
On any case, your solution below seems to be more elegant and independent on libraries.