Best and worst student

Report a typo

Let's say we have a class Student with the name and grade properties:

data class Student(val name: String, val grade: Int) : Comparable<Student> { }

Write a compareTo () method to sort the list of students by grade in descending order if the grade list is sorted alphabetically by name.

Write a program in Kotlin
data class Student(val name: String, val grade: Int) : Comparable<Student> {
override fun compareTo(other: Student): Int {
// put your code here
}
}
___

Create a free account to access the full topic