added functionality to sortidxs