Issue #276 has been updated by Matthew Boeh.


Your sortBySuit method appears to be doing nothing, because it's just assigning the sorted result to a local variable which is subsequently discarded. You might want to try 

  cards.replace(cards.sort_by {|card| card.suit })

Enumerable#take_while is behaving properly in your first case: 

"Passes elements to the block until the block returns nil or false, then stops iterating and returns an array of all prior elements."

That is, since your fourth card has suit == "D", #take_while stops at that point and never gets to your last card. 

In any case, the behavior you appear to be expecting is provided by Enumerable#select, not Enumerable#take_while.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/276

----------------------------------------
http://redmine.ruby-lang.org