Sorry for the noob question (i guess...).
Say I have an array of post_commenters with user_id & comment_id
E.g.:
1 - 27
2 - 31
1 - 54
3 - 87
1 - 12
2 - 54
If I wanted to rank the users by their number of comments, I'd have to count the number of times they have commented, and then .uniq it.
How can I do that ?
I know how to uniq it:
unique_user_list = array.uniq {|s| s.user_id}
I know how to count the duplicates inside the array:
array.count { |u| u.name == unique_user_list.name } # in a loop of user
But i'm at a loss to mix and sort by number of duplicates...
Thank you!
EDIT
Ok, thanks to floatless, i'm now at something more tangible - with a real example from the foursquare api, using quimby gem:
- current_user.all_checkins.group_by(&:venue["id"]).first(50).each do |c|
= c.venue.id
Only problem, it doesn't .... group.
Any idea?