Sorting algorithms/Selection sort: Difference between revisions

Content added Content deleted
(update for CL, works with lists and vectors)
(→‎{{header|Common Lisp}}: better example formatting)
Line 233: Line 233:
Example use:
Example use:


<pre>> (let ((l (list 8 7 4 3 2 0 9 1 5 6)))
<pre>> (selection-sort (list 8 7 4 3 2 0 9 1 5 6) '<)
(selection-sort l '<))
(0 1 2 3 4 5 6 7 8 9)
(0 1 2 3 4 5 6 7 8 9)


> (let ((l (vector 8 7 4 3 2 0 9 1 5 6)))
> (selection-sort (vector 8 7 4 3 2 0 9 1 5 6) '>)
(selection-sort l '>))
#(9 8 7 6 5 4 3 2 1 0)</pre>
#(9 8 7 6 5 4 3 2 1 0)</pre>