Is there an idiomatic way to sort an array in place in Perl? As far as I understand,
my @list = sort @list;
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?