- If the list has fewer than two items, you are done.
- Otherwise proceed as follows.
- Start at the beginning of the list.
- Move right one.
- Check your value and the value to the left. If they are in order, move right one.
- If they are out of order, swap them and move one to the left. If you are at the beginning, move right one.
- Once you skid off the right hand end of the list, you are done.
Implement this as an in-place sort in a function called gnome
.
You will implement the minisort
algorithm we discussed in
class.