diff --git a/desc/protoprint/print.go b/desc/protoprint/print.go index eed13352..1c2c4084 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 velue must be 0 in proto3 vj := dj.(*desc.EnumValueDescriptor) if vi.GetNumber() == vj.GetNumber() { return vi.GetName() < vj.GetName() } + if vi.GetFile().IsProto3() { + if vi.GetNumber() == 0 { + return true + } + if vj.GetNumber() == 0 { + return false + } + } return vi.GetNumber() < vj.GetNumber() case *descriptorpb.DescriptorProto_ExtensionRange: