Fixed algo for sort