Ruby For Rails Question

I am confused about the following method on page 415. Where did the b come from? What is the end.reverse?

def rank(list)
  list.uniq.sort_by do |a| {|b| a == b }.size

Hi --

The do block that begins "list.uniq ..." extracts unique
values from list, then sorts them by the expression: {|b| a == b }.size

This expression extracts sublists of list, where each item
(b) matches the current value of a. The "size" method then
tallies the number of elements in each sublist. In short,
we are sorting by the number of times that each unique item
appears in the initial list.

This gives us a list of instruments which is sorted by the
number of compositions in which it appears. "reverse" then
reverses the order of the sorted list. (I think :slight_smile:


P.S. This is really more of a Ruby question than a Rails one;
      you might want to post such to