Thanks for replying tarek2
I took a good look at your code. I knew it was that line I should change, but I still couldn't figure out how to do that. The other two lines above I had already disabled so as not to create the sequence again. But you are right. I was waiting for something closer to what I needed because I've wasted a lot of time on this project and it's just a demonstration of what I intend to do.
Analyzing that line you highlighted, this time in the first sequence, there is being stored in the new_sequence array, the order of the frames based on the variable seq1 and the order of the initial frames. You used (-1) to match the frame number since it starts at 0, right? Then, the value of the new_sequence array is passed to another variable (new_result). Despite knowing that I must change something in one of these expressions in that specific line, I think (for me) they are correct as they appear. Therein lies the dilemma.
The code of this sequence it is like this:
This is the result I am obtaining: