0

hi i have the next problem i have an array or arraylist from class Student which has firstname, lastname and grade.

How can i sort them by grade (value) - ascending and descending?

```
package zadacha_1;
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
public class Zadacha_2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<Student> students = new ArrayList<Student>();
students.add(new Student("Stefan", "Stefanov", 3));
students.add(new Student("Petar", "Petrov", 4));
students.add(new Student("Angel", "Angelov", 5));
students.add(new Student("Boiko", "Borisov", 6));
students.add(new Student("Georgi", "Parvanov", 3));
students.add(new Student("Atanas", "Atanasov", 4));
students.add(new Student("Naiden", "Naidenov", 5));
students.add(new Student("Georgi", "Georgiev", 6));
students.add(new Student("Pencho", "Penchev", 2));
students.add(new Student("Ivan", "Ivanov", 2));
Student[] arrayStudents = new Student[10];
for (int i = 0; i <10; i++){
arrayStudents[i] = students.get(i);
}
//Arrays.sort(arrayStudents);
for (Student name : arrayStudents){
System.out.println(name.getFirstName());
}
}
}
```