Skip to content

Commit

Permalink
use Double/Float.compare for stable and correct float sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
s1monw committed Apr 19, 2013
1 parent 1483a3a commit 7ea6cd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Expand Up @@ -62,13 +62,7 @@ public final FieldComparator<T> setNextReader(AtomicReaderContext context) throw
}

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 {
Expand Down
Expand Up @@ -39,13 +39,7 @@ public FloatValuesComparator(IndexNumericFieldData<?> indexFieldData, float miss
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
Expand Down

0 comments on commit 7ea6cd6

Please sign in to comment.