use Double/Float.compare for stable and correct float sort order
This commit is contained in:
parent
1483a3a0e5
commit
7ea6cd6888
|
@ -62,13 +62,7 @@ abstract class DoubleValuesComparatorBase<T extends Number> extends NumberCompar
|
|||
}
|
||||
|
||||
static final int compare(double left, double right) {
|
||||
if (left > right) {
|
||||
return 1;
|
||||
} else if (left < right) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return Double.compare(left, right);
|
||||
}
|
||||
|
||||
static final class MultiValueWrapper extends DoubleValues.Filtered {
|
||||
|
|
|
@ -39,13 +39,7 @@ public final class FloatValuesComparator extends DoubleValuesComparatorBase<Floa
|
|||
public int compare(int slot1, int slot2) {
|
||||
final float v1 = values[slot1];
|
||||
final float v2 = values[slot2];
|
||||
if (v1 > v2) {
|
||||
return 1;
|
||||
} else if (v1 < v2) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return Float.compare(v1, v2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue