Skip to content

Instantly share code, notes, and snippets.

@RomaniukVadim
Created November 17, 2018 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomaniukVadim/a421f4f46e5055e6d1690389bc10b220 to your computer and use it in GitHub Desktop.
Save RomaniukVadim/a421f4f46e5055e6d1690389bc10b220 to your computer and use it in GitHub Desktop.
Erlang nesting list sort
-module(sort_list).
-export([sort_list/1]).
sort_list(List) -> internal_sort_list(List, []).
internal_sort_list([], Acc) -> lists:sort(Acc);
internal_sort_list([H|T],Acc) ->
case H of
{F, S} when is_list(S) =:= true ->
Data = sort_list(S),
internal_sort_list(T, [{F, Data}|Acc]);
{F,S}-> internal_sort_list(T, [{F,S}|Acc])
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment