qsort([]) -> []; % If the list [] is empty, return an empty list (nothing to sort) qsort([Pivot|Rest]) -> % Compose recursively a list with 'Front' for all elements that should be before 'Pivot' % then 'Pivot' then 'Back' for all elements that should be after 'Pivot' qsort([Front || Front <- Rest, Front < Pivot]) ++ [Pivot] ++ qsort([Back || Back <- Rest, Back >= Pivot]).
qsort([]) -> []; % If the list [] is empty return an empty list (nothing to sort) qsort([Pivot|Rest]) -> % Compose recursively a list with 'Front' for all elements that should be before 'Pivot' % then 'Pivot' then 'Back' for all elements that should be after 'Pivot' qsort([Front || Front <- Rest, Front < Pivot]) ++ [Pivot] ++ qsort([Back || Back <- Rest Back >= Pivot]).