title: Perl: Numerical sort of arrays in a hash 2 (Schwarzian Transform)
body: <p>This is actually a follow-up of this thread: 
  <a href="https://stackoverflow.com/questions/7914931/perl-numerical-sort-of-arrays-in-a-hash/">Perl: Numerical sort of arrays in a hash</a></p>
  
  <p>I couldn't edit the original question because my current code is a bit different, so I'm just asking this as another question.</p>
  
  <p>Okay after using the Schwarzian Transform, I have this:</p>
  
  <pre><code>my @mylines =("0.899 0.92 cat", 
              "9.999 0.001 dog",
              "-0.52 0.3 humpty", 
              "13.52 0.09 bumbo",
              "-1.52 0.98 nanny",
              "3.52 0.34 lala");
  
  my @sorted = map { join ' ', @$_ }
               reverse sort { $a-&gt;[0] cmp $b-&gt;[0] or $a-&gt;[1] &lt;=&gt; $b-&gt;[1] }
               map { [ split ] } (@mylines);
  
  print "$_\n" for @sorted;
  </code></pre>
  
  <p>I would expect the output to be sorted first by the first column, then the second, but it turns out like this:</p>
  
  <pre><code>9.999 0.001 dog
  3.52 0.34 lala
  13.52 0.09 bumbo
  0.899 0.92 cat
  -1.52 0.98 nanny
  -0.52 0.3 humpty
  </code></pre>
  
  <p>I suppose that's because it's doing a character sort... but I need it numerically sorted. Do I need to put a java-like "parseInt()" somewhere in the sort function?</p>