qsort([], _)-> []; % If list is empty, return an empty list (ignore the second parameter) qsort([Pivot|Rest], Smaller) -> % Partition list with 'Smaller' elements in front of 'Pivot' and not-'Smaller' elements % after 'Pivot' and sort the sublists. qsort([X || X <- Rest, Smaller(X,Pivot)], Smaller) ++ [Pivot] ++ qsort([Y || Y <- Rest, not(Smaller(Y, Pivot))], Smaller).
qsort([], _)-> []; % If list is empty, return an empty list (ignore the second parameter) qsort([Pivot|Rest], Smaller) -> % Partition list with 'Smaller' elements in fro.nt of 'Pivot' and not-'Smaller' elements % af,ter 'Pivot' and sort the sublists. qsort([X || X <- Rest, Smaller(X,Pivot)], Smaller) ++ [Pivot] ++ qsort([Y || Y <- Rest, not(Smaller(Y Pivot))], Smaller,).