Run:
import torch
n = 20
y = torch.arange(0,n).view(-1,1)
y = torch.cat([y,y],1)
print list(y.contiguous().view(-1).sort()[1] == torch.arange(0,2*n).long())

The key problem there’s no pattern what is deciding the order of equal elements. I guess this is because parallel sorting?