Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Greetings programmers, I am looking for a module which implements a fast integer sorting algorithm for large lists like the Shell (as in the oil company) sort or the Quick sort. Any pointers appreciated! Thank you all.

Edit kudra, 2002-08-19 Changed title

  • Comment on Looking for numeric sort (was Simon Davey)

Replies are listed 'Best First'.
Re: Fast sort
by Aristotle (Chancellor) on Aug 19, 2002 at 10:03 UTC
    The sort builtin is implemented using Quicksort up to Perl 5.6.1; in 5.8 it has been switched to a stable Mergesort, and using physgreg's idiom will do what you want faster than any module written in Perl itself is ever likely to achieve.

    Makeshifts last the longest.

Re: Simon Davey
by physgreg (Scribe) on Aug 19, 2002 at 09:44 UTC
    The internal perl sort command can be used to sort numerically:
    @sorted_list = sort {$a<=>$b} @unsorted_list
    The <=> operator returns 0 if the two numbers are equal, -1 if $a<$b and 1 if $a>$b. Hope that helps.
Re: Simon Davey
by Abigail-II (Bishop) on Aug 19, 2002 at 11:08 UTC
    Shell sort wasn't named after the oil company, but after mister Shell.

    Abigail

      It's very similar to the monte sort, but works with peas instead of cards. But it's still limited to only three objects.

      --
      Tommy
      Too stupid to live.
      Too stubborn to die.