title: Ruby Sort_by multiple parameters opposite asc/desc
body: <p>Trying to sort by multiple parameters but having trouble with one parameter sorting ascendingly and the other descending.</p>
  <pre><code>array = [20, 10, 40, 1200, 300]
  </code></pre>
  <p>I need to first sort the array by the number of digits in each number descending.</p>
  <p>So we get <code>[1200, 120, 40, 10, 20]</code></p>
  <p>If there is a tie between lengths, I need to sort them ascendingly by value</p>
  <p>So we get: <code>[1200, 120, 10, 20, 40]</code></p>
  <p>I'm trying to make sort_by work for this but I can't figure out how to sort the first parameter descending and the second ascendingly.</p>
  <pre><code>def digit_sorter(ar) 
     ar.sort_by {|num| [num.to_s.length, num]}.reverse 
  end
  </code></pre>
  <p>I've also tried <code>[ [num.to_s.length], [num].reverse ]</code></p>