public int compareSwappedTo(DoubleIntPair other){
  int fdiff=this.second - other.second;
  if (fdiff != 0) {
    return fdiff;
  }
  return Double.compare(this.second,other.second);
}

public int compareSwappedTo ( DoubleIntPair other ) { int fdiff = this . second - other . second ; if ( fdiff != 0 ) { return fdiff ; } return Double . compare ( this . second , other . second ) ; }
implementation of comparableswapped interface , sorting by second then first .
