Sort fields before iterating over them, to create fewer spurious changes