1: // @author Frank M. Carrano, Timothy M. Henry
2: // @version 5.0
3: private void insertionSort()
4: {
5: // If fewer than two items are in the list, there is nothing to do
6: if (length > 1)
7: {
8: // Assertion: firstNode != null
10: // Break chain into 2 pieces: sorted and unsorted
11: Node unsortedPart = firstNode.getNextNode();
12: // Assertion: unsortedPart != null
13: firstNode.setNextNode(null);
15: while (unsortedPart != null)
16: {
17: Node nodeToInsert = unsortedPart;
18: unsortedPart = unsortedPart.getNextNode();
19: insertInOrder(nodeToInsert);
20: } // end while
21: } // end if
22: } // end insertionSort