From: Ricky Fleck
Subject: Writing your own sort routine
Date: 
Message-ID: <38C8978C.5529CFD9@4hiskids.org>
I was wondering if anyone could help me in writing my own sort function.
I know there is one that already exists, but I need to rewrite it
myself. All it needs to do is sort a list of positive integers into
increasing order.

Thanks for any help that can offered.

--Rick

From: Roger Corman
Subject: Re: Writing your own sort routine
Date: 
Message-ID: <38c94d13.67967482@nntp.best.com>
On Thu, 09 Mar 2000 22:34:52 -0800, Ricky Fleck <·····@4hiskids.org>
wrote:

>I was wondering if anyone could help me in writing my own sort function.
>I know there is one that already exists, but I need to rewrite it
>myself. All it needs to do is sort a list of positive integers into
>increasing order.
Here's a tip:
If you want to sort datasets of larger sizes, and get reasonable
performance, copy the list into an array and do the sort algorithm on
than. Then copy it back into a list (either the original or a new
one).

Roger Corman
From: Christopher Browne
Subject: Re: Writing your own sort routine
Date: 
Message-ID: <slrn8cjt2t.44m.cbbrowne@knuth.brownes.org>
Centuries ago, Nostradamus foresaw a time when Roger Corman would say:
>On Thu, 09 Mar 2000 22:34:52 -0800, Ricky Fleck <·····@4hiskids.org>
>wrote:
>>I was wondering if anyone could help me in writing my own sort function.
>>I know there is one that already exists, but I need to rewrite it
>>myself. All it needs to do is sort a list of positive integers into
>>increasing order.

>Here's a tip:
>If you want to sort datasets of larger sizes, and get reasonable
>performance, copy the list into an array and do the sort algorithm on
>than. Then copy it back into a list (either the original or a new
>one).

This sort of thing is quite common in general; it can be an improvement
in efficiency to construct a sequence in whatever haphazard order proves
most convenient, and then, once it is created, run through and sort it
*once,* in one fell swoop.

However, I suspect that the gentle questioner may be looking for
consulting assistance with a homework assignment.

In such cases, it is quite proper to offer the selection of any of the
following "service offerings:"

1.  Answers are available at the low, low hourly billing rate of $100/hr,
    with an 8 hour minimum fee, payable in advance.

2.  Answers are available free of charge, but in order for proper academic
    credit to be assessed, it is necessary to get the instructor's
    email address.  Answers will be submitted directly; no need for
    middlecritter.

3.  Hopefully the critical principles may be displayed by the example of
    the "bogosort" algorithm, a sort algorithm that is designed to have
    questionable/pessimal performance.  Something perhaps like:

    While not done, Loop:
       Pick two elements at random.
       Swap them.
       Walk through the list and see if it is now in ascending order.
          If so, End.
          If not, Loop.

The most fun option is to try varying algorithms for #3...
-- 
Appendium to  the Rules  of the  Evil Overlord #1:  "I will  not build
excessively integrated security-and-HVAC  systems.  They may be Really
Cool, but are far too vulnerable to breakdowns."
········@hex.net - - <http://www.hex.net/~cbbrowne/lsf.html>
From: Friedrich Dominicus
Subject: Re: Writing your own sort routine
Date: 
Message-ID: <38C89EDF.46B53780@inka.de>
Ricky Fleck wrote:
> 
> I was wondering if anyone could help me in writing my own sort function.
> I know there is one that already exists, but I need to rewrite it
> myself. All it needs to do is sort a list of positive integers into
> increasing order.
> 
> Thanks for any help that can offered.

Now you can check out e.g MzScheme, which contains a quicksort written
in Scheme. It should be not all too terrible to translate that into
Common Lisp. Anyway if one needs to re-write things which are quite
there and which are well documented, this has a smell of home-work. And
you won't find anyone here supporting writing your exercises and you
shouldn't seek for such kind of help too.

You can find e.g in Haskell a Craft of programming two liner for doing
quicksort on lists. So you may have a look.

Regards
Friedrich
From: Janos Blazi
Subject: Re: Writing your own sort routine
Date: 
Message-ID: <38cc0ce0_1@goliath.newsfeeds.com>
Ricky Fleck <·····@4hiskids.org> schrieb in im Newsbeitrag:
·················@4hiskids.org...
> I was wondering if anyone could help me in writing my own sort function.
> I know there is one that already exists, but I need to rewrite it
> myself. All it needs to do is sort a list of positive integers into
> increasing order.
>
> Thanks for any help that can offered.

There are a lot of sorting algorithms and the first step would be to choose
one of them. In your case sorting can be done very efficiently as your keys
are so simple. You have probably learnt such an algorithm.

J.B.




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
From: Janos Blazi
Subject: Re: Writing your own sort routine
Date: 
Message-ID: <38cc0ce2_1@goliath.newsfeeds.com>
> Thanks for any help that can offered.

There are mmany sorting algorithms and you have probably learnt some of
them. So the first step is to choose the algorithm. In your case sorting can
be done very fast as your keys are so simple. What Roger means is this:
Accessing elements of a list at random is expensive (O(n)) while elements of
arrays can be accessed in O(1) time. But this is not important at the
beginning.

Janos Blazi




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----