Punch (CA) Interview Question

Sort the array as per the rules of card game using generic method