optimization to hsort