• Re: Sort letters

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Sat Jul 5 23:28:41 2025
    From Newsgroup: comp.lang.lisp

    Actually, you can use STRING< for characters, symbols and strings.

    (defun sortit (diddel dudel)
    (loop for elem in (append diddel dudel)
    if (numberp elem) collect elem into numbers
    else collect elem into alfas
    finally (return (values (sort numbers #'<) (sort alfas #'string<)))))

    (sortit '(4 p 2 5) '(m 6 a v e))

    (2 4 5 6)
    (A E M P V)


    Gauche Scheme

    (define (sortit . lists)
    (receive (n a) (partition number? (concatenate lists))
    (values
    (sort n)
    (sort-by a x->string))))

    (sortit '(4 p 2 5) '(m 6 a v e) '(0 z 9) '(b 3))

    ===>
    (0 2 3 4 5 6 9)
    (a b e m p v z)

    --- Synchronet 3.21a-Linux NewsLink 1.2