<div dir="ltr">Looking at the maps API, I see no function that can present the contents of a map in the defined order.<div><br></div><div>Because there IS a defined order, described in the Erlang Reference Manual:</div><div><br></div><div>«Maps are ordered by size, two maps with the same size are compared by keys in ascending term order and then by values in key order. In maps key order integers types are considered less than floats types.»</div><div><br></div><div>Note that the key ordering described above doesn't follow normal Erlang term ordering, so lists:sort(maps:to_list(Map)) will produce something will a well-defined order, but comparing the sorted lists of two maps is not guaranteed to have the same outcome as comparing the maps themselves.</div><div><br></div><div>I can solve this by using lists:sort/2, but this seems contrived.</div><div><br></div><div>To clarify, e.g. msgpack:pack(Map) will perform a maps:to_list(Map). This is not guaranteed to produce the same result across Erlang versions, since maps:to_list/1 says pairs "are returned in arbitrary order".</div><div><br></div><div>Yet there is no alternative API function that will return pairs in the defined sort order, although presumably there is an efficient internal implementation for producing it.</div><div><br></div><div>Wouldn't it be reasonable to have such a function?</div><div><br></div><div>BR,</div><div>Ulf W</div></div>