package sortings;
public class SelectionSort {
public static void selects(int[] input)
{
for(int i=0;i<input.length-1;i++)
{
int min=input[i];
int minIndex=i;
for(int j=i+1;j<input.length;i++)
{
if(input[j]<min)
{
min=input[j];
minIndex=j;
}
}
if(minIndex!=i)//here i dont understand why we comparing minindex!=i if both are same
{
input[minIndex]=input[i];
input[i]=min;
}
}
}
public static void main(String[] args)
{
int input[]= {2,6,9,1,5};
selects(input);
for(int i=0;i<input.length;i++)
{
System.out.println(input[i]+ " ");
}
}
}
if(minIndex!=i)//here i dont understand why we comparing minindex!=i if both are same
{