This sort is also known as Bubble sort, which you can read in detail alongwith implementation in C [here][1].
By the way, bubble sort in perhaps the slowest sort algorithm with O(n*n) complexity.
So if you wanna use a sort algorithm in a programming contest, you ought to look for [MergeSort][2], [HeapSort][3], [QuickSort][4]
Or you may find about inbuilt sort function in your language which is usually fastest in most of cases…
Please UPVITE and Accept, if you find this helpful…
[1]: http://www.geeksforgeeks.org/bubble-sort/
[2]: http://www.geeksforgeeks.org/merge-sort/
[3]: http://www.geeksforgeeks.org/heap-sort/
[4]: http://www.geeksforgeeks.org/quick-sort/