-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDumpSorting.java
More file actions
50 lines (44 loc) · 1.01 KB
/
DumpSorting.java
File metadata and controls
50 lines (44 loc) · 1.01 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Arrays;
import java.util.List;
class dumpSorting {
public static void main(String[] args) {
System.out.println();
System.out.println("[12, 11, 9, 8]");
System.out.println();
System.out.println("[11, 9, 12, 8]");
System.out.println();
int a = 9;
int b = 12;
int c = 8;
int d = 11;
System.out.println(sort(a, b, c, d));
}
public static List<Integer> sort(int a, int b, int c, int d) {
if (a > b) {
int temp = b;
b = a;
a = temp;
}
if (c > d) {
int temp = d;
d = c;
c = temp;
}
if (a > c) {
int temp = c;
c = a;
a = temp;
}
if (b > d) {
int temp = d;
d = b;
b = temp;
}
if (b > c) {
int temp = c;
c = b;
b = temp;
}
return Arrays.asList(a, b, c, d);
}
}