cost sort