public static void selectSort(int[] a)
    {
        int min_index;
        for (int i = 0; i < a.length; i++) {
            min_index = i;
            for (int j = i + 1; j < a.length; j++) {
                if (a[j] < a[min_index]) {
                    min_index = j;
                }
            }
            /* exchange the min to a[i] */
            int tmp = a[i];
            a[i] = a[min_index];
            a[min_index] = tmp;
        }
    }