Changed the call to .sort.last to .max when computing the migration version. You
do not actually need to sort everything (incurs more cost than just a
simple max).
Merge pull request #9818 from wangjohn/sort_last_to_max_in_migration_version

Changed the call to .sort.last to .max when computing the migration version