Finished work on median sort, now it properly works.