Skip to content

Instantly share code, notes, and snippets.

@fogonthedowns
Created July 29, 2014 04:37
Show Gist options
  • Save fogonthedowns/ef1fce13df04cdfb08ad to your computer and use it in GitHub Desktop.
Save fogonthedowns/ef1fce13df04cdfb08ad to your computer and use it in GitHub Desktop.
frequency
x = {"Alanine"=>7.4, "Arginine"=>4.2, "Asparagine"=>4.4, "Aspartic Acid"=>5.9, "Cystine"=>3.3,
"Glutamic Acid"=>5.8, "Glutamine"=>3.7, "Glycine"=>7.4, "Histidine"=>2.9, "Isoleucine"=>3.8,
"Leucine"=>7.5, "Lysine"=>7.2, "Methionine"=>1.8, "Phenylalanine"=>4.0, "Proline"=>5.0,
"Serine"=>8.0, "Threonine"=>6.2, "Tryptophan"=>1.3, "Tyrosine"=>3.3, "Valine"=>6.8,
"Stop Codons"=>0.1}
x.sort_by {|_key, value| value}
=>[["Stop Codons", 0.1], ["Tryptophan", 1.3], ["Methionine", 1.8], ["Histidine", 2.9],
["Tyrosine", 3.3], ["Cystine", 3.3], ["Glutamine", 3.7], ["Isoleucine", 3.8], ["Phenylalanine", 4.0],
["Arginine", 4.2], ["Asparagine", 4.4], ["Proline", 5.0], ["Glutamic Acid", 5.8], ["Aspartic Acid", 5.9],
["Threonine", 6.2], ["Valine", 6.8], ["Lysine", 7.2], ["Glycine", 7.4], ["Alanine", 7.4], ["Leucine", 7.5],
["Serine", 8.0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment