Implemented sortHeap, updated "tests", and refactored a bit for code reuse.