Created
November 17, 2018 23:11
-
-
Save RomaniukVadim/a421f4f46e5055e6d1690389bc10b220 to your computer and use it in GitHub Desktop.
Erlang nesting list sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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