title: How to sort a Ruby Hash alphabetically by keys
body: <p>I am trying to sort a Hash alphabetically by key, but I can't seem to find a way to do it without creating my own Sorting class. I found the code below to sort by value if it's an integer and I am trying to modify it but not having any luck. </p>
  
  <pre><code>temp["ninjas"]=36
  temp["pirates"]=12
  temp["cheese"]=222
  temp.sort_by { |key, val| key }
  </code></pre>
  
  <p>My goal is to order the Hash by key then output the values. I will have to do this multiple times with different hash orders but the same values.</p>