Heapsort like algorithm but not the identical one