title: Ruby: sort array of hashes, even though key may not exist
body: <p>In a rails application, I have an array of hashes which I can sort easily with just</p>
  
  <pre><code>array_of_hashes.sort_by { |hash| hash[:key_to_sort] }
  </code></pre>
  
  <p>But what if not every array member has a key <code>:key_to_sort</code>?  Then the sort will fail "comparison of String with nil failed".  Is there a way to allow the sort to continue?  Or is there another way to do this?</p>