#C11967. Sorting People by Age and Salary

    ID: 41341 Type: Default 1000ms 256MiB

Sorting People by Age and Salary

Sorting People by Age and Salary

You are given a list of people where each person is represented by three pieces of information: a name (a string without spaces), an age (an integer), and a salary (an integer). Your task is to sort the list of people by increasing age. However, if two people have the same age, the person with the higher salary should come first.

In addition, you must format the output such that each person’s details are printed on a new line in the format: name age salary.

The sorting criteria can be expressed mathematically as follows:

[ (a_1, s_1) < (a_2, s_2) \quad \text{if} \quad a_1 < a_2 \quad \text{or} \quad (a_1 = a_2 \quad \text{and} \quad s_1 > s_2) ]

Here, (a) represents the age and (s) represents the salary. Use LaTeX formatting for any formulas.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n), which represents the number of people. Each of the following (n) lines contains one person's details in the format: name age salary. The fields are separated by spaces.

outputFormat

The output should be written to standard output (stdout). Print exactly (n) lines, each containing a single person's details formatted as name age salary, in the sorted order as specified.## sample

3
Alice 25 50000
Bob 25 60000
Charlie 30 40000
Bob 25 60000

Alice 25 50000 Charlie 30 40000

</p>