The way I see it you work with parallel arrays.
So each data is distributed over two arrays. Therefore you cannot sort one alone but the connected list must change as well.
One way is that you use a class (define a data structure) that holds x and y. Then you make a array of that class.
Actually that’s basically PVector.
Or make your own class, see text tutorials objects