Let's say I have an array of random numbers in a specific order. Let's say this is ID # for people who ran in a marathon, and they are added to the array in the order in which they end, for example:
race1 = [8, 102, 67, 58, 91, 16, 27]
race2 = [51, 31, 7, 15, 99, 58, 22]
This is a simplified and somewhat contrived example, but I think it conveys the basic idea.
Now a few questions:
First, how can I get the identifiers that are before and after a certain record? Let's say I'm looking at runner 58, and I want to know who finished before and after him.
race1, runner58: previous finisher=67, next finisher=91
race2, runner58: previous finisher=99, next finisher=22
Secondly, if I look at the person who finished the first or last, how can I get the “next” or “previous” loop around the array?
race1, runner8: previous finisher=27, next finisher=102
race2, runner22: previous finisher=58, next finisher=51
, , . , , "" ? :
race1: runner8=1st, runner102=2nd, runner67=3rd ... runner27=last
!