A class Student stores a name and the marks of a student. The main code reads some students, sorts them with Collections.sort and prints them.
Write the method compareTo so that the students are sorted from the lowest marks to the highest marks.
If two students have the same marks, their order must stay as it was in the input (so compareTo returns 0 for them).
The first line has n, the number of students. Each of the next n lines has a name (one word) and the marks (an integer).
Print the students after sorting, one per line, as name marks.
Input:
3
Asha 72
Ravi 55
Meena 90
Output:
Ravi 55
Asha 72
Meena 90

A class `Student` stores a name and the marks of a student. The main code reads some students, sorts them with `Collections.sort` and prints them. Write the method `compareTo` so that the students are sorted from the lowest marks to the highest marks. If two students have the same marks, their order must stay as it was in the input (so `compareTo` returns 0 for them). ### Input Format The first line has `n`, the number of students. Each of the next `n` lines has a name (one word) and the marks (an integer). ### Output Format Print the students after sorting, one per line, as `name marks`. ### Example Input: ``` 3 Asha 72 Ravi 55 Meena 90 ``` Output: ``` Ravi 55 Asha 72 Meena 90 ``` The main code reads some words and sorts them with `Collections.sort(words, new ByLength())`. Write the class `ByLength`, a `Comparator<String>`, so that shorter words come first. Words with the same length must stay in the order they had in the input. ### Input Format The first line has `n`, the number of words. The second line has the `n` words (each one is a single word, separated by spaces). ### Output Format Print the sorted words on one line, separated by one space. ### Example Input: ``` 3 bb a ccc ``` Output: ``` a bb ccc ``` The main code reads some integers and sorts them with `Collections.sort(list, new HighFirst())`. Write the class `HighFirst`, a `Comparator<Integer>`, so that the biggest number comes first. All the numbers fit in an `int`, and they can be negative or very large. ### Input Format The first line has `n`, the number of integers. The second line has the `n` integers. ### Output Format Print the sorted integers on one line, separated by one space. ### Example Input: ``` 4 -5 3 -20 0 ``` Output: ``` 3 0 -5 -20 ```