Skip to content

Commit

Permalink
Fix #3712: PrimeReact.nullSortOrder working properly (#3713)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 28, 2022
1 parent 1d2f6bd commit 85b5ff9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/lib/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,20 @@ export default class ObjectUtils {

static sort(value1, value2, order = 1, locale, nullSortOrder = 1) {
const result = ObjectUtils.compare(value1, value2, locale, order);
let finalSortOrder = order;

// nullSortOrder == 1 means Excel like sort nulls at bottom
const finalSortOrder = nullSortOrder === 1 ? order : nullSortOrder;
if (ObjectUtils.isEmpty(value1) || ObjectUtils.isEmpty(value2)) {
finalSortOrder = nullSortOrder === 1 ? order : nullSortOrder;
}

return finalSortOrder * result;
}

static compare(value1, value2, locale, order = 1) {
let result = -1;
const emptyValue1 = this.isEmpty(value1);
const emptyValue2 = this.isEmpty(value2);
const emptyValue1 = ObjectUtils.isEmpty(value1);
const emptyValue2 = ObjectUtils.isEmpty(value2);

if (emptyValue1 && emptyValue2) result = 0;
else if (emptyValue1) result = order;
Expand Down

0 comments on commit 85b5ff9

Please sign in to comment.