Why is the chronological order of recording secondary particles from largest to smallest

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_10.7.1
_Operating System:_ubuntu 18
Compiler/Version:
_CMake Version:_3.10.1

These are the output data
|70|5|0.190313971|10.20216738|4|
|70|3|1.71423732|7.229379318|4|
|70|2|2.511974991|4.786597321|4|

How to make these become:
|70|2|2.511974991|4.786597321|4|
|70|3|1.71423732|7.229379318|4|
|70|5|0.190313971|10.20216738|4|

The tracking stack in Geant4 is a LIFO stack. The last track created is the next one processed. If you have a more complex event (let’s say a calorimeter shower), then you’ll see that the tracks are not in any kind of time order at all.

I know LIFO stack.
But when I output primary particles, their time order is correct.

This is the code in SteppingAction:

if( ParNum==2112 && PID==0 && aStep->GetPostStepPoint()->GetTouchableHandle()->GetVolume() != NULL && Energy>0.1 )
{
if( Vname1 == “World” && Vname2 == DET[1] ) //&& StNum==2 )
{outfile002<<std::setprecision(10)<<EID<<" “<<TID<<” “<<StNum
<<” “<<Energy<<” “<<time01 <<” W "<<Vname2<<G4endl;}
}
output:
|25|1|2|0.6745190082|9.209798394|W|12|
|25|1|7|0.4936308782|28.78901719|W|7|
|25|1|13|0.2062048756|39.6639165|W|1|

if( ParNum==2212 && StNum==1 && PID==1 && Energy>0.1 && Vname1 != “World” && Vname1 != “CfSn” )
{
outfile100<<std::setprecision(10)<<EID<<" “<<TID<<” “<<Energy<<” "
<<time01<<" "<<Vname1<<G4endl;
}
output:
|70|5|0.190313971|10.20216738|4|
|70|3|1.71423732|7.229379318|4|
|70|2|2.511974991|4.786597321|4|

I don’t know why