-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraySort
More file actions
30 lines (25 loc) · 812 Bytes
/
ArraySort
File metadata and controls
30 lines (25 loc) · 812 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
// Create a program to sort any amount of command line inputs from least to greatest
// Created: Apr 18 2020
public class arraySort {
public static void main(String[] args) {
int c = 0;
int [] array;
int size = args.length;
array = new int[size];
for (int k = 0; k < array.length; k++) {
array[k] = Integer.parseInt(args[k]);
}
for (int j = 0; j < array.length; j++) {
for (int i = 0; i < array.length-1-j; i++) {
if (array[i] > array[i+1]) {
c = array[i];
array[i] = array[i+1];
array[i+1] = c;
}
}
}
for (int k = 0; k < array.length; k++ ) {
System.out.println(array[k]);
}
}
}