title: Wrap perl's sort function in an object
body: <p>I'm trying to make a sort function available in one of my (object-oriented) packages that accepts a block and makes available $a and $b like the standard Perl <code>sort</code>. </p>
  
  <p>First, a simplified version of what I'm trying to do in the package that contains the wrapped sort function:</p>
  
  <pre><code># In package My::Object
  sub sort {
    my $self = shift;
    my $block = \&amp;{shift @_};
  
    return sort $block @{$self-&gt;{arrayRef}}; # I want to use the passed in block with array data contained in this object
  }
  </code></pre>
  
  <p>And then an example of a client passing a block which defines the comparitor to run for the sort:</p>
  
  <pre><code>my $obj = My::Object-&gt;new([3, 1, 5, 6, 2, 4]); # As an example, these values will be come arrayRef from above
  my @sortedVals = $obj-&gt;sort({ $a &lt; $b });
  </code></pre>
  
  <p>Is there a way to do what I'm trying to do while still being able to use Perl's <code>sort</code>?</p>