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

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