protocolbuffers / txtpbfmt

txtpbfmt parses, edits and formats text proto files in a way that preserves comments.
Apache License 2.0
99 stars 19 forks source link

Sort all children and also sort adjacent children with the same name. #104

Closed copybara-service[bot] closed 1 year ago

copybara-service[bot] commented 1 year ago

Sort all children and also sort adjacent children with the same name.

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.

In order to follow the requirements of Less, we need to individually sort each subslice.