package com;
/**
* @author leon
*
*/
public class SelectSort {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SelectSort selectSort = new SelectSort();
int arr[]={49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51};
selectSort.selectSort(arr);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]);
System.out.print(",");
}
}
public void selectSort(int arr[]){
for (int i = 0; i < arr.length; i++) {
int posistionValue = arr[i];
int minIndex = i;
int minValue = arr[i];
int j = i+1;
for (; j < arr.length; j++) {
if (arr[j] < minValue) {
minValue = arr[j];
minIndex = j;
}
}
arr[minIndex] = posistionValue;
arr[i] = minValue;
}
}
}