Fix bug #20 and #21 by using more stable sorting

Implemented quick sort instead of heap sort. I couldn't
figure out why all test cases was successful except for a list of
3 items that are already sorted.