(Sorry this took so long, I was going to explain a fancy sorting algorithm when I realized that I could make it way simpler)

We first have to give each racer a different ID that can identify them. This can be their name, or the color of the car, but I'll just use a number for now. I'm not exactly sure how to implement this without seeing your project first, but here's the main concept:

When each racer is “spawned” or created, you can set a variable to an ID. If you're using clones for the different racers, you will need to make the variable for this sprite only. This is a unique ID that will be used to tell which racer is in which place.
set [carID v] to [change this value based on the car (EX. blue or Mario or P1)]
Next, we have to set each racer's score. Again, i'm not sure exactly how to implement this without seeing your project, but here's the main concept.

We will score the racers based on their time. We can store the scores in a list that i'll call scoreboard. We can also store the car IDs in a list.

Here's some code I whipped up:

When the race is started, use the
reset timer
block.
We also want to reset the lists at the start of the race:
delete (all v) of [scoreboard v]
delete (all v) of [carIDs v]

Next, we have to get the racer's time when they cross the finish line. Add this code onto whatever code detects when a car reaches the finish line:

add (carIDs) to [carIDS v]
add (timer) to [scoreboard v]
You can then use these values in a text engine or something like that to display the winners. Alternatively, you can keep it simple by displaying the scoreboard with a list. Instead of the above code, use this:

When the race is started:
reset timer
delete (all v) of [Scoreboard v]
When car crosses finish line:
add (join (join (carID) [: ]) (timer)) to [Scoreboard v]
//this code will add the player and their time to the scoreboard list
Now all we have to do is show the list when the race ends.
show list [Scoreboard v]
should do the trick! We also should hide it when the flag is clicked and/or when you go back to the menu if you have one in your game. You can use
hide list [Scoreboard v]
==================================
I hope this helps! Let me know if you get stuck, and I will try to help you out.