/*	
	Mr. Bui
	10/4/06
	This program sorts the integer array using the selection sort algorithm
*/

public class SelectionSort
{
	public static void main(String [] args)
	{
		int [] intArray = { 1, 2, 3, 4, 5, 1, 6, 42, 4, 6 ,3, 4, 2, 6, 7, 
			6, 4, 63, 12, 4, 7, 4, 2, 1, 3, 5, 7, 8, 7, 32, 56, 5, 35, 10 }; 
			

		int currentMinIndex = 0;

		for (int front = 0; front < intArray.length; front++)
		{
			//initialize currentMin to the element in the current front
			currentMinIndex = front;
			
			for (int i = front; i < intArray.length; i++)
			{
				//find the minimum element (use currentMinIndex)
				if (intArray[i] < intArray[currentMinIndex])
				{
					currentMinIndex = i;
				}
			}
			
			//swap found minimum with the current "front"
			int tmp = intArray[front];
			intArray[front] = intArray[currentMinIndex];
			intArray[currentMinIndex] = tmp;
		}

		//print out sorted array
		for(int i = 0; i < intArray.length; i++)
		{
			System.out.println(intArray[i]);
		}
	}
}