Make sure versions are dumped in order

There is not any guarantees that versions comes in the same order they
are inserted without ordering them explicitely.
Merge pull request #277 from hiukkanen/master

Migrated versions should be dumped in order