def sort_hand(hand, deck):
    """Returns a hand of cards sorted in the index order of the given deck"""
    sorted_hand = []
    for i in deck:
        for card in hand:
            if i == card:
                sorted_hand.append(card)
    return sorted_hand