Split out sort_direction() helper method.