java算法选择排序:
/**
* 选择排序:
*
*/
public class SelectionSort {
public void sort(int[] data) {
for (int i = 0; i < data.length; i++) {
int lowIndex = i;
for (int j = data.length - 1; j > i; j--) {
if (data[j] < data[lowIndex]) {
lowIndex = j;
}
}
swap(data, i, lowIndex);
}
}
private void swap(int[] data, int i, int j) {
int temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}