# open file # array each word # ["wonky",8] # # read in as array raw_read = File.open('stories.txt','r').read posts_array = raw_read.split('----------------------------------------------------------') #formatted_posts_array = [] #for post in posts_array ## post.split('**body_of_post**') # formatted_posts_array #end keywords = {} for post in posts_array words_array = post.split(' ') # separate out words for word in words_array if keywords.include? word keywords[word] += 1 else # isn't indexed add it keywords.merge! word => 1 end end end #a = { "sad" => 9, "der" => 2, "add" => 12 } keywords = keywords.sort_by {|key, value| value} for word in keywords p word end