dbp has asked for the wisdom of the Perl Monks concerning the following question:
incurs the overhead of creating a new array and copying the values into @list; we get the same result as sorting a list in place but at greater cost. It is conceivable that Perl is optimized to take advantage of code like this, but I don't know one way or another. One could easily write a sub that performs some sorting algorithm (quicksort, mergesort, etc) on an array reference, but is there a way to coerce Perl's built-in functions to get the desired effect?my @list = sort @list;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting Array in Place
by dws (Chancellor) on Nov 24, 2002 at 23:57 UTC | |
|
Re: Sorting Array in Place
by pg (Canon) on Nov 25, 2002 at 00:02 UTC | |
by dbp (Pilgrim) on Nov 26, 2002 at 00:22 UTC | |
|
Re: Sorting Array in Place
by Anonymous Monk on Oct 29, 2012 at 19:46 UTC |