Sort lists from maps

The undocumented order of elements in lists generated from maps changed
in OTP 26, so enforce old order by sorting them.
diff --git a/src/couch_log/src/couch_log_formatter.erl b/src/couch_log/src/couch_log_formatter.erl
index 91b64ad..cc8b5d8 100644
--- a/src/couch_log/src/couch_log_formatter.erl
+++ b/src/couch_log/src/couch_log_formatter.erl
@@ -467,12 +467,14 @@
     %% https://www.rfc-editor.org/rfc/rfc5424.html#section-6.3
     %% iut="3" eventSource="Application" eventID="1011"
     string:join(
-        maps:fold(
-            fun(K, V, Acc) ->
-                [to_str(K, V) | Acc]
-            end,
-            [],
-            Meta
+        lists:sort(
+            maps:fold(
+                fun(K, V, Acc) ->
+                    [to_str(K, V) | Acc]
+                end,
+                [],
+                Meta
+            )
         ),
         " "
     ).
diff --git a/src/couch_log/src/couch_log_trunc_io.erl b/src/couch_log/src/couch_log_trunc_io.erl
index 9736e87..c330edb 100644
--- a/src/couch_log/src/couch_log_trunc_io.erl
+++ b/src/couch_log/src/couch_log_trunc_io.erl
@@ -352,7 +352,7 @@
         _ -> {"...", 3}
     end;
 map_body(Map, Max, Options) ->
-    case maps:to_list(Map) of
+    case lists:sort(maps:to_list(Map)) of
         [] ->
             {[], 0};
         [{Key, Value} | Rest] ->
diff --git a/src/couch_log/test/eunit/couch_log_formatter_test.erl b/src/couch_log/test/eunit/couch_log_formatter_test.erl
index 29d5497..cdb7eae 100644
--- a/src/couch_log/test/eunit/couch_log_formatter_test.erl
+++ b/src/couch_log/test/eunit/couch_log_formatter_test.erl
@@ -38,9 +38,8 @@
         bar => "barStr",
         baz => baz
     }),
-    % NOTE: this currently hardcodes the ordering of the keys, however, map
-    % key order is not guaranteed and this may break.
-    Formatted = "[foo=123 baz=\"baz\" bar=\"barStr\"]",
+    % Rely on `couch_log_formatter:format_meta/1` to sort keys
+    Formatted = "[bar=\"barStr\" baz=\"baz\" foo=123]",
     ?assertEqual(Formatted, lists:flatten(Entry#log_entry.msg)).
 
 format_reason_test() ->