Order is taken from the moment of caution, less cars in an incident state (be it the yellow-causing incident or another incident state). The incident cars are then placed in order based on where they recover.
Example:
Cars 54, 64, and 8 are in a three-car draft for P1, P2, and P3. Cars 36 and 73 are in a two-car draft 2 seconds back. Cars 68 and 67 are 6 and 10 seconds back, respectively. Cars 64 and 8 collide and spin, Car 36 cannot react in time and gets involved. Cars 68 and 67 contiune on without incident, only slowing in response to the yellow. Car 8 recovers quickly and carries on before 67 and 68 overtake him, attaining at least the SC pace before they overtake him. Car 36 recovers before Car 64. Result: 54, 8, 68, 67, 36, 64.
NOTE: Even if you never were part of the incident and are faster than the car that has recovered from being in an incident state, as long as any car is at or above SC pace (or within a reasonable window, usually +/- 10 kph) it is considered active and on-course (NOTE: The car must be on track [between the white lines] - a car on the grass or off-track runoff is in an incident state always, even if making foward progress! Although, you should beware that they could spin off the grass or elsewhere without warning, and that to accelerate to overtake them may not always be the best idea. But it will always be the other guy's fault if he's on the grass and trying to give it the beans to not lose position - PROVIDED you're leaving room for that other car - the onus is on the incident car to avoid compounding the incident; there's also a responsibility of the cars still on track to avoid incidents.
AT ALL TIMES: YELLOW Flag = No overtaking, racing is to cease.