Refactors the way of sorting columns