public class selectionsorter
  {
public selectionsorter(int[] x)
{
    theArray=x;
}
public void sort()
{
    for(int i=0; i<theArray.length-1;i++)
    {
        start=i;
        findMinPos();
    }
}
public void findMinPos()
{
    int minpos=start;
    for(int i=0;i<theArray.length;i++)
    {
        if(i>start)
        {
        if(theArray[i]<theArray[start])
        {
        start=i;
        }
        }
    }
    swap();
}
public void swap()
{
    temp=theArray[start];
    theArray[start]=theArray[minpos];
    theArray[minpos]=temp;
}
private int[] theArray;
private int minpos;
private int start;
private int temp;
   }
Tester File
   public class selectionsortertester
  {
public static void main(String[] args)
{
    int[] x ={3,7,5,6,9,2};
    selectionsorter y=new selectionsorter(x);
    y.sort();
    for(int i=0; i<x.length;i++)
    System.out.print(x[i]+" ");
}
  }
I want it to sort the array it from lowest to highest and it does the first number, and the output is "2 7 5 6 9 3" Please Help and Thanks Does anyone know why it is doing this and how I can fix it, Thanks
 
     
     
    