From: "Kroeger, Simon (ext)" Date: 2006-06-06T23:05:43+09:00 Subject: Re: mode > -----Original Message----- > From: Daniel N [mailto:has.sox@gmail.com] > Sent: Tuesday, June 06, 2006 2:54 PM > To: ruby-talk ML > Subject: Re: mode > > Hi Micheal, > > I could not get your example to work properly. It seemed to > return the > count of the highest number in my initial list. > > I modified it to > > li.inject(Hash.new(0)){|s,v| s[v] += 1; s}.invert.max.last > > and it gave me the result I expected. Is it just me tho? another one: li.sort_by{|x| li.select{|y| x==y}.length}.last cheers Simon