I bet there's a more elegant way to write this. Anyone want to show me?

def mode(li)
   best_num = nil
   best_count = -1
   li.uniq.each do |item|
     count = (li.select { |item2| item == item2}).length
     if count > best_count
       best_count = count
       best_num = item
     end
   end
   best_num
end


-- Elliot Temple
http://www.curi.us/blog/