-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsortList.java
More file actions
32 lines (23 loc) · 749 Bytes
/
sortList.java
File metadata and controls
32 lines (23 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.*;
import java.util.ArrayList;
class Employee{
int employeeId;
int salary;
public Employee(int employeeId,int salary){
this.employeeId=employeeId;
this.salary=salary;
}
}
public class sortList{
public static void main(String args[]){
//Comparator<Employee> com=(e1,e2)->(e1.salary>e2.salary)? 1:-1;
List<Employee> emp =new ArrayList<>();
emp.add(new Employee(1,6000));
emp.add(new Employee(2,5130));
emp.add(new Employee(3,6020));
Collections.sort(emp,(e1,e2)->Integer.compare(e1.salary,e2.salary));
for(Employee e:emp){
System.out.println(e.salary);
}
}
}