/* javac SelectSort.java
* java SelectSort 5 3 4 2 1 9 8 7 6
*
* */
public class SelectSort {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = new int[args.length];
for (int i=0; i<args.length; i++) {
arr[i] = Integer.parseInt(args[i]);
System.out.print(arr[i] + " ");
}
System.out.println();
if (arr.length > 0) {
selectSort(arr);
}
for (int i=0; i<arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
public static void selectSort(int parr[]) {
int k;
int node;
for (int i=0; i<parr.length; i++) {
k = i;
for (int j=k+1; j<parr.length; j++) {
if (parr[j] < parr[k]) {
k = j;
}
}
if (i != k) {
node = parr[i];
parr[i] = parr[k];
parr[k] = node;
}
}
}
}