mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Preserve order of grouped duplicates
This commit is contained in:
parent
f6d7af1a2b
commit
925998c360
@ -232,13 +232,18 @@ format_join(L) ->
|
|||||||
%% into a single option with all list-values being concatenated
|
%% into a single option with all list-values being concatenated
|
||||||
-spec group_dups(list(T)) -> list(T).
|
-spec group_dups(list(T)) -> list(T).
|
||||||
group_dups(Y1) ->
|
group_dups(Y1) ->
|
||||||
{Y2, D} = lists:mapfoldl(
|
lists:reverse(
|
||||||
|
lists:foldl(
|
||||||
fun({Option, Values}, Acc) when is_list(Values) ->
|
fun({Option, Values}, Acc) when is_list(Values) ->
|
||||||
{[], dict:append_list(Option, Values, Acc)};
|
case lists:keyfind(Option, 1, Acc) of
|
||||||
|
{Option, Vals} when is_list(Vals) ->
|
||||||
|
lists:keyreplace(Option, 1, Acc, {Option, Vals ++ Values});
|
||||||
|
_ ->
|
||||||
|
[{Option, Values}|Acc]
|
||||||
|
end;
|
||||||
(Other, Acc) ->
|
(Other, Acc) ->
|
||||||
{[Other], Acc}
|
[Other|Acc]
|
||||||
end, dict:new(), Y1),
|
end, [], Y1)).
|
||||||
lists:append(Y2) ++ dict:to_list(D).
|
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Validators from yconf
|
%%% Validators from yconf
|
||||||
|
Loading…
Reference in New Issue
Block a user