Solved by KFrank in post #2 
              
              
                Hello Usami! 

I do not believe that pytorch’s sort() supports a custom sort order 
or comparator argument. 
But you can implement it relatively easily.  The idea will be to look up 
your values to be sorted in your comparison-order vectors, and then 
sort those indices. 
Note that in your example u…