You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the Kth attribute and print the final resulting table. Follow the example given below for a better understanding.
Rank | Age | Height(in cm) |
1 | 32 | 190 |
2 | 35 | 175 |
3 | 41 | 188 |
4 | 26 | 195 |
5 | 24 | 176 |
Sorting based on K=1 i.e(age)
Rank | Age | Height |
5 | 24 | 176 |
4 | 26 | 195 |
1 | 32 | 190 |
2 | 35 | 175 |
3 | 41 | 188 |
Note that K is indexed from 0 to M-1, where M is the number of attributes.
Constrain: If two attributes are the same for different rows, for example, if two athletes are of the same age, print the row that appeared first in the input.
Kindly comment the code for the above problem statement and
GUVIan who comments first with the correct code would win a Premium course of their choice.
Results will be declared by next week!!
Hurry up!!