Punch (CA) interview question

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