Find an element in hash with minimum index value
int res_ind = int . MaxValue , res = 0 ; foreach ( KeyValuePair < int , int > x in hash ) { if ( x . Value < res_ind ) { res_ind = x . Value ; res = x . Key ; } } return res ; }