diff --git a/desc/protoprint/print.go b/desc/protoprint/print.go index eed13352..c7c286d0 100644 --- a/desc/protoprint/print.go +++ b/desc/protoprint/print.go @@ -2137,11 +2137,20 @@ func (a elementAddrs) Less(i, j int) bool { return vi.GetNumber() < vj.GetNumber() case *desc.EnumValueDescriptor: - // enum values ordered by number then name + // enum values ordered by number then name, + // but first value number must be 0 in proto3 vj := dj.(*desc.EnumValueDescriptor) if vi.GetNumber() == vj.GetNumber() { return vi.GetName() < vj.GetName() } + if vi.GetFile().IsProto3() { + if vj.GetNumber() == 0 { + return false + } + if vi.GetNumber() == 0 { + return true + } + } return vi.GetNumber() < vj.GetNumber() case *descriptorpb.DescriptorProto_ExtensionRange: