• Re: Sort letters

    From B. Pym@21:1/5 to All on Sat Jul 5 23:28:41 2025
    XPost: comp.lang.scheme

    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)