sort filenames so merging works correctly

quick fix: sort the keys of the filename map so that the records are written in the right order for merging.