class HotTopicFinder
def initialize
@array = ["montreal", "toronto", "montreal", "canada", "montreal", "toronto", "food", "montreal", "food"]
@queries = []
read_array
end
def read_array
@hash = Hash.new(0)
@array.each do |query|
@hash[query] += 1
end
sort_array
end
def sort_array
@queries = @hash.sort_by{ |k, v| v }.reverse
end
def find_hot_topics(number_of_topics)
@queries.slice(0, number_of_topics)
end
end