It's a reference to an anonymous array which is created in the same step as the return statement. Why would it duplicate it?

Going from right to left:
keys %bigHash
generates a list, containing the values in the hash.
sort {...}
Manipulates the list according to the sort rule (sorts in ascending numerical order of the value associated with the key). Still a list.
[...] #now the brackets
the brackets tell Perl that "hey, this list in here? gimme a ref to an array with those elements in that order. This is the first point where it's an array in your example. It's unclear where you think copying an array is occurring. There's no practical difference between
my @foo=sort @bar; return \@foo;
and
my $foo=[sort @bar]; return $foo;
unless you try to manipulate the array in the subroutine, in which case you'd need to deal with @$foo in the second example. sort operates on a list and returns a list. If you use an array to feed it, it doesn't change the original array. The array you're worried about copying isn't an array yet at that point, so there's no risk of copying it.

(And as a general note, if you aren't observing what appears to be a resource-driven slowdown, you should usually not try to out-think the language implementation, because in certain circumstances you can interfere with compiler-level optimization)

Edit: I think perlreftut might provide some enlightenment.

In reply to Re^3: Reference to sort results by ssandv
in thread Reference to sort results by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.