new function: sortidx