Sorting an array of vectors in javascript

I'm filling an array with Vector4s and I want to sort them to get the lowest entries at the top (only the last two points relate to a position in the vector 4, the first two relate to distances, which is why I want to bring up the shortest. I'm using a vector 4 because I need all of this information to stay together during the sort. The first two numbers both need to be relevant to the sort so that if the first numbers are identical it will sort by the second number.)

I used to convert the Vector4s to strings before entering them into the array, but that winds up failing to pull the lowest number because the sort will favor 100 over 94, as it only sees individual characters.

If anybody has any advice for resolving this I'd be very grateful.

See this question.

Also, rather than having to use Vector4's, you could define a class to contain the data.