Skip to content

Instantly share code, notes, and snippets.

@jonathanhudak
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanhudak/9964a6486420a875030b to your computer and use it in GitHub Desktop.
Save jonathanhudak/9964a6486420a875030b to your computer and use it in GitHub Desktop.
sorting array of hashes
def getUserInfo(client, name)
friendTweets = client.user_timeline(name)
@tweets = Array.new
friendTweets.each do | tweet |
text = tweet.text if tweet.is_a?(Twitter::Tweet)
vowels = text.scan(/[aeiou]/).count
tweetInfo = {'text' => text, 'vowels' => vowels}
@tweets.push(tweetInfo)
end
@tweetsByVowelTotal = @tweets.sort_by { |tweet| tweet[:vowels] }
puts @tweetsByVowelTotal.reverse
end
getUserInfo(client, 'wintr_us')
@calebkm
Copy link

calebkm commented Jun 14, 2014

Same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment