adkt
9/17/2014 - 9:52 PM

Selection Sort

template<typename T>
void selectionSort(T * const array, const int size)
{
	int smallest;
	int temp;

	for (int j=0; j<size; j++)
	{
		smallest = j;
		for(int i=j; i<size; i++)
		{
			if(array[i]<array[smallest])
			{
				smallest = i;
			}
		}
		temp = array[j];
		array[j] = array[smallest];
		array[smallest] = temp;
	}
}