Sort pair
Comparator < pair > comp = new Comparator < pair > ( ) { public int compare ( pair e1 , pair e2 ) { if ( e1 . first < e2 . first ) { return - 1 ; } else if ( e1 . first > e2 . first ) { return 1 ; } else { return 0 ; } } } ;