package com.zhangry; public class SelectSort { public static void main(String[] args) { int[] array = {2,1,3,5,4,9,6,8,7,6,5,4,5,55,5,5,5,46,456,876,34,534,}; selectSort(array); for(int i : array){ System.out.print(i+","); } } private static void selectSort(int[] array) { int len = array.length; int temp =0; for (int i = 0; i < len; i++) { int minIndex = 0; for (int j = i; j < len; j++) { if(j==i){ minIndex = j; } if (array[j] < array[minIndex]) { minIndex = j; } } temp = array[i]; array[i] = array[minIndex]; array[minIndex] = temp; } } }