sorry, I’m back.
If I am using torch.sort(b) then the internal order of all 1s in b is disturbed. It means the inds=[2, 0, 1], not inds=[0, 2, 1]. Is there a way to get b sorted but not disturb elements internal ordering?