用 Python 内置的排序:

import random

suits = 'SHCD'
ranks = '23456789TJQKA'

def sort(pokers):
    def tmp(poker):
        return (suits.index(poker[0]), ranks.index(poker[1]))
    return sorted(pokers, key=tmp)

pokers = [s + r for s in suits for r in ranks]
random.shuffle(pokers)
print pokers
print sort(pokers)

或者自己手写快排:

import random

suits = 'SHCD'
ranks = '23456789TJQKA'

def val(poker):
    return (suits.index(poker[0]), ranks.index(poker[1]))

def quick_sort(pokers):
    if not pokers:
        return []
    return quick_sort([p for p in pokers[1:] if val(p)<val(pokers[0])]) +\
           pokers[0:1] +\
           quick_sort([p for p in pokers[1:] if val(p)>=val(pokers[0])])

pokers = [s + r for s in suits for r in ranks]
random.shuffle(pokers)
print pokers
print quick_sort(pokers)