How to sort different values from highest to smallest?

As title says, how do i arrange 8 values from highest to smallest?

To make situation clear: I have 8 variable floats (distances from the finish line in racing game) and i want them to place as above while knowing on which place is my chosen variable (player’s ship)

I think you’re looking for the sort function. You can find it here.

Put your values into an array, and then you can sort them with one call:

var distances = new Array (2, 3, 1);