ProAnswers.org

algorithm Selection Sort

algorithm Selection Sort

#define SWAP(x, y, t) ((t) = (x), (x) = (y), (y) = (t))

	void select_sort(int list[], int length){

	    int i, j, temp;

	    for(i = 0; i < length - 1; i++)

	    {

	        for(j = i + 1; j < length; j++)

	        {

	            if(list[i] > list[j])

	                SWAP(list[i], list[j], temp);

	        }

	    }

	}