From: Farrel Lifson Date: 2006-03-17T22:04:14+09:00 Subject: Re: Card tricks with Ruby I think you're confusing the <=> operator needed to mixin Enumerable. The block in sort_by just returns a value that the sort_by method should assign to each element in the array so that they may be ordered. The returned value itself could be anything as long as it implements Comparable (or it might just need <=>). So for instance when you say deck.sort_by do |card| card.suite end the sort_by method get's all the values of the suites of the cards in the deck and then sorts them according to that. The suite could be a string ("Hearts") or a numeric value (0=Hearts, 1=Diamonds etc). For instance [1,2,3,4].sort_by do |number| number % 2 end will return [4,2,3,1]. Because the value of the block can either be 0 or 1 the array is sorted into two 'chunks': 4 & 2 (number % 2 ==0) 1 & 3 (number % 2 == 1). Farrel