vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

In Perl I read sort operator for sorting, Do we have any module for different type of sorting to use like insertion sort, selection sort etc..

Replies are listed 'Best First'.
Re: Sort types
by kennethk (Abbot) on Mar 23, 2009 at 14:39 UTC
    First, using the sort pragma, you can swap between quicksort and mergesort for the behavior of the built-in sort function. Second, there are other sorting algorithms available on CPAN, which you can find with the search terms you listed above, e.g. Algorithm::SISort, Data::Sorting.
Re: Sort types
by salva (Canon) on Mar 24, 2009 at 11:25 UTC
    What is your aim with this question?

    If you want to use a different sorting algorithm because you think it would be more efficient for your particular data because it has some property as being already partially sorted, then, you should now that the "mergesort" used internally by perl already handles most common special cases. For instance, sorting and almost sorted array is an O(N) operation.

    Sort::Key::Radix is a radixsort implementation, that can outperform perl internal mergesort for several key types.