Create an auxiliary array of next row with the element and it 's position
List < Tuple < int , int > > aux = new List < Tuple < int , int > > ( ) ; for ( int j = 0 ; j < m ; ++ j ) { aux . Add ( new Tuple < int , int > ( V [ i + 1 , j ] , j ) ) ; }