From: Thomas A. Russ
Subject: Re: Please holp to sort number.....
Date: 
Message-ID: <ymihgheg43f.fsf@hobbes.isi.edu>
In article <·············@sel.chonbuk.ac.kr> �� â ȣ <·····@sel.chonbuk.ac.kr> writes:

 > Hi! every one.. I'm just learned lisp.
 > In this case I can't sort in order of numver..
 > So, I need your help..
 > Please, let me know what I mistake.
 > This is my source to sort number in order.
 > 
 > (defun isort (num)
 >   (if (< (length num) 2) num
 >     (if (> (first num) (first (rest num)))
 >        (isort (append (isort (rest num)) (list (first num))))
 >       (append (list (first num)) (isort (rest num))))))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If the first element of the top level call is smaller than the second
element, then the first element is never compared to any succeeding
elements of the list.  It is returned as the first element.

 > I try to
 > "(isort '(59 70 23 1 2 34 54 5 7 8))".
 > 
 > But the result is
 > "(59 1 2 5 7 8 23 34 54 70)"
 > 
 > I don't know what I mistake..  Please let me know..

One way to track this problem down is to try evaluating the code by
hand, starting with a smaller input set like, for example: (59 70 23 1)

 > I'll greatly appreciate your KINDNESS..
 > Thank you....

Meta Comment:  This will be a rather inefficient sort algorithm.

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu