#!/usr/bin/python3

import random

# my card data
faces = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
         "Eight", "Nine", "Ten", "Jack", "Queen", "King")
suits = ("Clubs", "Hearts", "Spades", "Diamonds")

ranks = {"Ace" : 14, "Two" : 2, "Three" : 3, "Four" : 4,
         "Five" : 5, "Six" : 6, "Seven" : 7, "Eight" : 8, 
         "Nine" : 9, "Ten" : 10, "Jack" : 11, "Queen" : 12, "King" : 13}

# let's define a custom sort function
def sorter(card):
    return ranks.get(card.split()[0])

# lets build the deck, starting with an empty deck
deck = []

# let's loop thru the suits
for currentSuit in suits:
    # let's loop thru the faces
    for currentFace in faces:
        deck.append(currentFace + " of " + currentSuit)


picks = random.sample(deck, 5)

picks.sort()

print("Sorted by Card Face")
# let's now print those cards sorted by Card Face name
for currentPick in picks:
    print(currentPick)

print("*****************")

picks2 = sorted(picks, key=sorter)

print("Sorted by Card Rank")
# let's now print those cards sorted by Card Rank
for currentPick in picks2:
    print(currentPick)
