However, this is not the only way in which sorting can be done. It's often best to ground sorting algorithms in practical experience. I'll bring in a stack of my CDs and we'll consider ways to sort them. First, I'll just hand you stacks of CDs and ask you to describe what you're doing. We'll continue by looking at the instructions you wrote for today.
Selection sort is among the simpler and more natural methods for sorting.
In this sorting algorithm, you segment the array into two subparts, a sorted part and an unsorted part. You repeatedly find the largest of the unsorted elements, and put that at the beginning of the sorted part. This continues until there are no unsorted elements. This is a tail-recursive algorithm, so there shouldn't be any. Another simple sorting technique is insertion sort .