Panagiotis Atmatzidis wrote in post #1067854: > I'm not even sure if the enumerable method 'any' is used > correctly. No, it's not how it's intended to be used. The idea behind 'any?' is to return true if the block returns true for any of the elements. So the block is expected to return a "truthy" value. puts [1,3,7,4].any? { |x| x > 10 } # false puts [1,3,7,4].any? { |x| x > 5 } # true However, because your block ends with a "p" statement, which always returns nil, this will be treated as false always. So in this case, 'any?' is really behaving just as 'each', just iterating over every single element. Also, you're ignoring the return value from 'any?' > Any hints or ideas on how to adjust/improve this piece of code are > welcomed! Why are you not just taking 'sorted.first' as the most frequently found element? If you are concerned about getting all the equal top values, then I'd do something like this: best_count = sorted[0][1] return sorted.select { |data,no| no == best_count } Regards, Brian. -- Posted via http://www.ruby-forum.com/.