Improved syncModifications(...): group + sort by local revision first.