Newsgroups: comp.lang.lisp
From: cyber_surfer@wildcard.demon.co.uk (Cyber Surfer)
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!news.sprintlink.net!demon!wildcard.demon.co.uk!cyber_surfer
Subject: Re: Quick Sort in LISP?
References: <36p2vv$h1@basfigw.basf-corp.com> <36pc4q$1ig@tools.near.net>
Organization: The Wildcard Killer Butterfly Breeding Ground
Reply-To: cyber_surfer@wildcard.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27
Lines: 22
Date: Wed, 5 Oct 1994 15:15:14 +0000
Message-ID: <781370114snz@wildcard.demon.co.uk>
Sender: usenet@demon.co.uk

In article <36pc4q$1ig@tools.near.net>
           barmar@nic.near.net "Barry Margolin" writes:

> (defun sort-file (filename)
>   (let ((lines
>           (with-open-file (s filename)
>             (loop for line = (read-line s nil nil)
>                   while line collect line))))
>     (setq lines (sort lines #'string-<))
>     (mapc #'write-line lines)))

It could also be done using the series functions:

(defun sort-file (filename)
    (let ((lines (collect (scan-file filename #'read-line))))
        (mapc #'write-line (sort lines #'string-<))))

The series functions aren't a part of CL, of course, but they
can be found in the Lisp Repository.
-- 
"Internet? What's that?" -- Simon "CompuServe" Bates
http://cyber.sfgate.com/examiner/people/surfer.html
