Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→{{header|Scheme}}: Fix formatting, simplified, better variable names
m (→{{header|Go}}: library change) |
(→{{header|Scheme}}: Fix formatting, simplified, better variable names) |
||
Line 2,335:
Here is a recursive bubble sort which sorts list 'l' using the comparator 'f':
<lang scheme>(define (bsort
l)
(else
(cond ((equal? l r) l)▼
(cons (car l) (dosort (cdr l))))))
(let ((try (dosort l)))
l
(bsort try gt?))))
</lang>
For example, you could do
<lang scheme>(bsort > '(
(1 2 3)</lang>
|