-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSort.java
More file actions
31 lines (29 loc) · 773 Bytes
/
Sort.java
File metadata and controls
31 lines (29 loc) · 773 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
package com.tyss.finalassessment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Sort {
public void sort(ArrayList<StudentDetails> list,Scanner scanner) throws Exception{
if(list.isEmpty()) {
System.out.println("your list is empty");
return;
}
System.out.println("enter the option\n 1.id\n 2.name\n 3.mark");
int input=scanner.nextInt();
switch (input) {
case 1:
SortById byId = new SortById();
Collections.sort(list, byId);
break;
case 2:
SortByName byName = new SortByName();
Collections.sort(list, byName);
break;
case 3:
SortByMark byMark = new SortByMark();
Collections.sort(list, byMark);
break;
}
System.out.println("List of the students are sorted");
}
}