def pick(number, *cards)
      ordered = cards.flatten.map do |card|
        i = card_preference.map { |preference| card.type == preference }.index(true)
        {card: card, index: i}
      end
      ordered.sort_by { |h| h[:index] || 99 }.first(number).map {|h| h[:card] }
    end
def pick(number, *cards)
      ordered = cards.flatten.map do |card|
        i = card_preference.map { |preference| card.type == preference }.index(true)
        {card: card, index: i}
      end
      ordered.sort_by { |h| h[:index] || 99 }.first(number).map {|h| h[:card] }
    end
def pick ( number , * cards ) ordered = cards . flatten . map do | card | i = card_preference . map { | preference | card . type == preference } . index ( true ) { card : card , index : i } end ordered . sort_by { | h | h [ :index ] || 99 } . first ( number ) . map { | h | h [ :card ] } end
you have the option of picking from many cards, pick the best one.
you have the option of picking from many cards pick the best one .