Insert into position vector according to infront value
for ( let i = 0 ; i < vp . length ; i ++ ) { let height = vp [ i ] [ 0 ] ; let k = vp [ i ] [ 1 ] ; pos [ k ] = height } let first = - 1 , second = - 1 ; for ( let i = 0 ; i < pos . length ; i ++ ) { if ( pos [ i ] == a ) first = i ; if ( pos [ i ] == b ) second = i ; } return Math . abs ( first - second ) ; }