-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBubbleShort.java
More file actions
57 lines (44 loc) · 1.29 KB
/
BubbleShort.java
File metadata and controls
57 lines (44 loc) · 1.29 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
51
52
53
54
55
56
57
package questions2;
import java.util.Arrays;
import java.util.Collections;
public class BubbleShort {
public static void main(String[] args) {
// Logic 1 Bubble Short
// int a[] = {3, 2, 1, 4,6,5};
// System.out.println("Array Befor Sorting = "+ Arrays.toString(a));
//
// int n = a.length;
//
// for(int i =0; i<n-1; i++) {
//
// for(int j=0; j<n-1; j++) {
//
// if(a[j] > a[j+1]) {
//
// int temp =a[j];
//
// a[j] = a[j+1];
// a[j +1] = temp;
// }
// }
// }
// System.out.println("Array After Sorting = "+ Arrays.toString(a));
//Logic 2 sort Element
// int a[] = {3, 2, 1, 4,6,5};
//
// System.out.println("Array Befor Sorting = "+ Arrays.toString(a));
// Arrays.parallelSort(a);
// System.out.println("Array After Sorting = "+ Arrays.toString(a));
// Logic 3 sort Accending Order
// int a[] = {3, 2, 1, 4,6,5};
//
// System.out.println("Array Befor Sorting = "+ Arrays.toString(a));
// Arrays.sort(a);
// System.out.println("Array After Sorting = "+ Arrays.toString(a));
// Logic 4 Decending Order
Integer a[] = {3, 2, 1, 4,6,5};
System.out.println("Array Befor Sorting = "+ Arrays.toString(a));
Arrays.sort(a,Collections.reverseOrder());
System.out.println("Array After Sorting = "+ Arrays.toString(a));
}
}