Sorting | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sorting

If the list of students and their mark is taken as input than can anyone tell to srt them and fing the students with above then 80% marks

22nd Jan 2019, 4:57 PM
Sankalp Pandey
Sankalp Pandey - avatar
1 Answer
+ 5
I'm assuming students is a class and mark is an attribute of class student and you are saving each instance of student to a data structure like an ArrayList. If mark is the ONLY attribute that you will use for sorting, then implement the Comparable interface and then override the compareTo method. In case you want to have more than one way of sorting your class objects, then you should use comparators. 
22nd Jan 2019, 7:33 PM
Lambda_Driver
Lambda_Driver - avatar