diff --git a/lib/protox/define.ex b/lib/protox/define.ex index cef66399..00948719 100644 --- a/lib/protox/define.ex +++ b/lib/protox/define.ex @@ -52,6 +52,7 @@ defmodule Protox.Define do # credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity defp define_messages(messages) do for {msg_name, syntax, fields} <- messages do + fields = Enum.sort(fields, &(elem(&1, 0) < elem(&2, 0))) unknown_fields = make_unknown_fields(:__uf__, fields) struct_fields = make_struct_fields(fields, unknown_fields, syntax) required_fields = make_required_fields(fields)