Make restoring from snapshots more efficient.
When restoring a snapshot, restore files in order roughly determined by how
they are stored in segments, instead of in pure lexicographic order. This
should ensure that, for the most part, each segment only has to be unpacked
once, instead of perhaps many times as could happen previously, and so
should make restoring more efficient.
This implementation loads all metadata into memory to determine the
ordering, and so restores are now much more memory-intensive than before.
It would be good to work on memory requirements later--either offer an
option to use the old behavior, or perhaps load some of the data into a
temporary database.