optimized sorted return for accumulate_range