Solved by phan_phan in post #4 
              
              
                Hi, 
You can get the permutation by calling perm = hc1.argsort(dim=0).squeeze(). 
In your example it returns tensor([2, 1, 0, 4, 3]) 
Then you can rearrange hc2 with this permutation : hc2_rearranged = hc2[perm]. 
In your example it returns 
tensor([[3.],
        [2.],
        [1.],
        [5.],
  …