; friday fun
(define (stalin-sort lt? xs)
(let loop ((xs (cdr xs)) (zs (list (car xs))))
(if (null? xs) (reverse zs)
(if (lt? (car zs) (car xs))
(loop (cdr xs) (cons (car xs) zs))
(loop (cdr xs) zs)))))
(display (stalin-sort < '(4 2 3 6 1 5)))
OyBmcmlkYXkgZnVuCiAKKGRlZmluZSAoc3RhbGluLXNvcnQgbHQ/IHhzKQogIChsZXQgbG9vcCAoKHhzIChjZHIgeHMpKSAoenMgKGxpc3QgKGNhciB4cykpKSkKICAgIChpZiAobnVsbD8geHMpIChyZXZlcnNlIHpzKQogICAgICAoaWYgKGx0PyAoY2FyIHpzKSAoY2FyIHhzKSkKICAgICAgICAgIChsb29wIChjZHIgeHMpIChjb25zIChjYXIgeHMpIHpzKSkKICAgICAgICAgIChsb29wIChjZHIgeHMpIHpzKSkpKSkKIAooZGlzcGxheSAoc3RhbGluLXNvcnQgPCAnKDQgMiAzIDYgMSA1KSkp