Java program for the above approach
import java . util . * ; class GFG { static class Pair implements Comparable < Pair > { int first ; double second ; Pair ( int f , double s ) { first = f ; second = s ; } @ Override public int compareTo ( Pair o ) { if ( this . second > o . second ) return 1 ; else if ( this . second == o . second ) return 0 ; return - 1 ; } }