We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dbf3e7e + b7198a4 commit c33f233Copy full SHA for c33f233
1 file changed
danfojs/src/core/utils.js
@@ -663,15 +663,22 @@ export class Utils {
663
}
664
665
__sort(arr, ascending = true) {
666
-
667
- let collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
668
let sorted = arr.slice();
669
670
- if (ascending) {
671
- return sorted.sort(collator.compare);
672
- } else {
673
- return sorted.sort((a, b) => collator.compare(b, a));
674
- }
+ return sorted.sort((a, b) => {
+ if (ascending) {
+ if ((typeof a === "string") && typeof b === "string") {
+ return a.charCodeAt() - b.charCodeAt();
+ } else {
+ return a - b;
+ }
675
676
+ return b.charCodeAt() - a.charCodeAt();
677
678
+ return b - a;
679
680
681
+ });
682
683
684
0 commit comments