Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
sort_repeated_fields_by_subfield
transitive and stable.
https://pkg.go.dev/sort#Interface says: > Less must describe a transitive ordering: > - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well. > - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well. The previous implementation tried to sort only adjacent fields, but this meant it didn't follow the requirements of `Less`. This made the sorting unstable for inputs like the attached bug. The new implementation makes the order transitive and stable. The next change will fix `sort_repeated_fields_by_content` which has the same problem. PiperOrigin-RevId: 561255014
- Loading branch information