====== Ascending sorting ====== {{tag>sorting lists math}} ===== Description ===== Sorting elements from the lowest to the greatest **Source**: PROLOG str. 190 Wydawnictwo PLJ Warszawa 1991 ISBN 83-85190-63-5 ===== Download ===== Program source code: {{ :pl:prolog:pllib:ascending_sorting.pl |}} ===== Listing ===== rosn([], []). rosn([X|T], S1) :- rosn(T, St), wstaw(X, St, S1). wstaw(X, [Y|S1], [Y|Sl1]) :- X>Y, !, wstaw(X, S1, Sl1). wstaw(X, S1, [X|S1]). test :- rosn([4, 7, 9, 5, 2], R). ===== Comments =====