If I understand what you've described correctly, you want to sort y and break ties among elements in y that have the same value based on the corresponding elements of x. Is that right? If so, you can pack the two vectors into a matrix and use sortrows to sort first by the column corresponding to y then by the column corresponding to x. In my sample code below, the y column is column 2 and the x column is column 1 so I sortrows using [2 1].
x = [0,50,150,100,50,150,0,100,150,0,50,150]
y = [1,2,3,3,2,1,1,2,3,3,2,1]
M = [x.', y.']
M2 = sortrows(M, [2 1])
If you need to know which row in M went to which row in M2 (or equivalently which elements in x and y went where in M2) call sortrows with two outputs.