Here is another solution to the problem. I got the idea for this while
reading Dale Martenson's solution.
It doesn't really "solve" the problem, instead it cheats ;-) , but on the
other side it is short and should be correct if the order hash is correct.
Dominik
order = {
"Spades" => "JsJcAsKsQsTs9sAdKdQdJdTd9dAcKcQcTc9cAhKhQhJhTh9h",
"Hearts" => "JhJdAhKhQhTh9hAsKsQsJsTs9sAdKdQdTd9dAcKcQcJcTc9c",
"Clubs" => "JcJsAcKcQcTc9cAhKhQhJhTh9hAsKsQsTs9sAdKdQdJdTd9d",
"Diamonds" => "JdJhAdKdQdTd9dAcKcQcJcTc9cAhKhQhTh9hAsKsQsJsTs9s"
}
trump = gets.strip
puts trump, readlines.map { |l| l.strip }.sort_by { |card|
order[trump].index(card)
}