Implemented MinHeap and MaxHeap to sorted array routines