Sort the tup vector sort ( tup . begin ( ) , tup . end ( ) ) ;
Collections . sort ( tup , new Comparator < int [ ] > ( ) { public int compare ( int [ ] a , int [ ] b ) { if ( a [ 0 ] == b [ 0 ] ) { if ( a [ 1 ] == b [ 1 ] ) { return a [ 2 ] - b [ 2 ] ; } else { return a [ 1 ] - b [ 1 ] ; } } return a [ 0 ] - b [ 0 ] ; } } ) ; curr = tup . get ( 0 ) [ 1 ] ; currPos = tup . get ( 0 ) [ 2 ] ;