public virtual int CompareTo(object o) { IntDoublePair ob = (IntDoublePair)o; if (this.d > ob.d) { return(1); } else if (this.d < ob.d) { return(-1); } else { return(0); } }
/// <summary> Sorts a, buts the smallest values into outD and the indices into outI</summary> private void Sort(double[] a, double[] outD, int[] outI) { // Sort both data and indices IntDoublePair[] ra = new IntDoublePair[a.Length]; for (int i = 0; i < a.Length; ++i) { ra[i] = new IntDoublePair(this, a[i], i); } Array.Sort(ra); // Extract the smallest for (int i = 0; i < outD.Length; ++i) { outD[i] = ra[i].d; outI[i] = ra[i].i; } }