-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsort.java
More file actions
36 lines (30 loc) · 730 Bytes
/
sort.java
File metadata and controls
36 lines (30 loc) · 730 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
33
34
35
36
class sort
{
public static void main(String[ ]args)
{
int [] a = {5,4,3,2,1};
int b = 0;
System.out.println("ARRAY BEFORE SORTING: ");
for (int i = 0; i < a.length; i++)
{
System.out.print(a[i] + " ");
}
for (int i = 0; i < a.length; i++)
{
for (int j = i+1; j < a.length; j++)
{
if(a[i] > a[j])
{
b = a[i];
a[i] = a[j];
a[j] = b;
}
}
}
System.out.println("\nARRAY AFTER SORTING IN ASCENDING ORDER: ");
for (int i = 0; i < a.length; i++)
{
System.out.print(a[i] + " ");
}
}
}