bugfixing type rating
This commit is contained in:
parent
1d0e18e56f
commit
2fa6443506
@ -482,12 +482,29 @@
|
|||||||
valueA = new Date(a[key]);
|
valueA = new Date(a[key]);
|
||||||
valueB = new Date(b[key]);
|
valueB = new Date(b[key]);
|
||||||
break;
|
break;
|
||||||
|
case "rating":
|
||||||
case "string":
|
case "string":
|
||||||
valueA = a[key]?.toUpperCase();
|
// Retrieve values
|
||||||
valueB = b[key]?.toUpperCase();
|
valueA = a[key];
|
||||||
|
valueB = b[key];
|
||||||
|
|
||||||
|
// Handle null or undefined values, always placing them at the bottom
|
||||||
|
if (valueA == null && valueB == null) {
|
||||||
|
return 0; // Both are null/undefined, no need to change the order
|
||||||
|
} else if (valueA == null) {
|
||||||
|
return 1; // null goes to the bottom
|
||||||
|
} else if (valueB == null) {
|
||||||
|
return -1; // null goes to the bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the values to uppercase for case-insensitive comparison
|
||||||
|
valueA = valueA?.toUpperCase();
|
||||||
|
valueB = valueB?.toUpperCase();
|
||||||
|
|
||||||
|
// Perform the sorting based on ascending or descending order
|
||||||
return sortOrder === "asc"
|
return sortOrder === "asc"
|
||||||
? valueA.localeCompare(valueB)
|
? valueA?.localeCompare(valueB)
|
||||||
: valueB.localeCompare(valueA);
|
: valueB?.localeCompare(valueA);
|
||||||
case "number":
|
case "number":
|
||||||
default:
|
default:
|
||||||
valueA = parseFloat(a[key]);
|
valueA = parseFloat(a[key]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user