package com.challenger;
import com.challenger.Util;
public class SelectSortDoWhile
{
public static void main(String[] args)
{
//define array
int[] arr={5,8,2,3,7,4,10,6,9,1};
//define i as array loop index
int i;
//define min as minium index
int min;
//define j as each loop to use for compare number
int j;
//define temporary number for exchange
int tmp;
i=1;
do
{
min=i;
j=min+1;
do
{
//j-1 and min-1 both represent j and min in array index
if(arr[j-1]<arr[min-1])
{
min=j;
}
j++;
}
while(j<=arr.length);
tmp=arr[i-1];
arr[i-1]=arr[min-1];
arr[min-1]=tmp;
i++;
}
while(i<=arr.length-1);
Util.printArray(arr);
}
}