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;
In reply to Sorting Array in Place by dbp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |