Student of the Year
Submissions: 2558   Accuracy:

31.52%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork CPP

Given a vector containing name of N student (in lowercase letters) and their marks in an exam. The task is to sort the students with respect to their marks (student with highest marks will be on top). If marks are same, consider lexicographic sorting for names.

 

Input Format:
First line of input contains number of testcases T. First line of each testcase contains N, number of students. Next line contains data of N students name and marks seperated by space (name, marks).

Output Format:
For each testcase, output the name of students with their marks in decreasing order, each student in new line.

Your Task:
Since this is a function problem, you don't need to take any input. You just need to complete the provided function sortMarks().

Constraints:
1 <= T <= 100
1 <= N <= 106
1 <= marks <= 106

Example:
Input:

1
4
michal 56
john 100
abbas 98
jordan 45

Output:
john 100
abbas 98
michal 56
jordan 45

Explanation:
Testcase 1:
marks of students in decreasing order is as 100, 98, 56, 45. So, their names are as john 100, abbas 98, michal 56, jordan 45.

** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.