Would it be good to have some sort of sanity check here that sort_dir is either "+" or "". Seem like someone could pass something else and cause problems.