Sort neighbors of every node and find the Kth node
for ( int i = 0 ; i < V ; i ++ ) { if ( ( ( ArrayList ) g [ i ] ) . Count > 0 ) { ArrayList tmp = ( ArrayList ) g [ i ] ; tmp . Sort ( new sortHelper ( ) ) ; g [ i ] = tmp ; }