[racket] complex sort or how to sort lines

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Fri May 25 12:35:02 EDT 2012

On Fri, May 25, 2012 at 6:16 PM, Don Green <infodeveloperdon at gmail.com> wrote:
> Given the output of Racket's read-words/line function, which produces a list
> of lists. Each word is in a list, each group of words on a line is in a
> list, all within a list.
>
> Any ideas on how to sort on the car (first element) of each list that
> corresponds to a line?

(define (sort-line line)
  (sort line
        (λ (a b)
          (or (null? a)
              (and (not (null? b))
                   (string<? (first a) (first b)))))))


Posted on the users mailing list.