Problem

As a good and responsible parent, the instructor is teaching his children how to play cards1. Although they are pretty good at counting, the children still struggle with determining which cards have the highest value due to the fact that some cards have faces rather numbers and that you also have to factor in suits for when the values are the same.

For this problem, you are to read in a series of cardholders and their corresponding cards, and then display the cardholders in the order of highest card value to lowest.

Inspiration

I just made this one up.

Input

You will be given a series of hands from standard input in the follow format:

N
Name1 Rank1 Suit1
...
NameN RankN SuitN

The input will be terminated by a non-positive N value.

Output

You are to order the cardholders of each input set and display them such that the person with the highest card value comes first, while the person with the lowest card value comes last. Separate cardholders with ", ":

NameHighest, ..., NameLowest

You must use the ordering above as the rules of precedence for both Rank and Suit. (Note: you should use the Suit in the case of a tied Rank.)

Example

Given the following input:

4
Peter 10 D
Caleb 9 H
Abigail J H
Madeline J S
-1

Your program should output the following:

Madeline, Abigail, Peter, Caleb

Hints

Submission

To submit your solution, you must initiate a Merge Request in your private assignments repository and assign it to the appropriate TA from the Challenge 04 - TA assignment list.

Development Branch

To facility the Merge Request workflow, you must do your development in its own branch:

$ cd path/to/repo                   # Go to your repository
$ git checkout master               # Make sure we are on master branch
$ git pull                          # Make sure we have changes for GitLab
$ git pull upstream master          # Fetch and merge upstream changes
$ git checkout -b challenge04       # Create challenge04 branch
...                                 # Do your work
$ git commit                        # Commit your work (can do this multiple times)
$ git push -u origin challenge04    # Push branch to GitLab

  1. They'll need to figure out a way to pay for college.