Binary trees can be used to implement a sorting method.
1. Extend the package BinaryTree.m from Section 6.3 by a function InOrder[tree $]$. The function should return all records of the tree in a list in the following order: first, the elements of the left subtree (recursively); then, the element at the root; finally, the elements of the right subtree. Because of the ordering of the binary tree, the resulting list will be sorted.
2. Use InOrder[tree] to implement a sorting function TreeSort [list] that sorts the list by first inserting all its elements into a binary tree and then converting the tree back into a list.