Commit 7872a53 1 parent b3c9429 commit 7872a53 Copy full SHA for 7872a53
File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 302
302
}
303
303
304
304
if ( Selector ) {
305
+ // let selectors = Selector.split(/,(?![^()]*\))/g);
305
306
306
307
let selectors = Selector . split ( ',' ) ;
307
308
for ( let j = 0 ; j < selectors . length ; j ++ ) {
654
655
return true
655
656
}
656
657
658
+
657
659
function sortData ( data , sort ) {
660
+ return data . sort ( ( a , b ) => {
661
+ for ( let i = 0 ; i < sort . length ; i ++ ) {
662
+ let key = sort [ i ] . key ;
663
+ if ( a [ key ] == null && b [ key ] == null ) continue ;
664
+ if ( a [ key ] == null )
665
+ return sort [ i ] . direction === 'desc' ? - 1 : 1 ;
666
+ if ( b [ key ] == null )
667
+ return sort [ i ] . direction === 'desc' ? 1 : - 1 ;
668
+
669
+ if ( typeof a [ key ] !== typeof b [ key ] ) {
670
+ return typeof a [ key ] < typeof b [ key ] ? - 1 : 1 ;
671
+ }
672
+
673
+ if ( a [ key ] !== b [ key ] ) {
674
+ if ( typeof a [ key ] === 'string' ) {
675
+ return sort [ i ] . direction === 'desc' ?
676
+ b [ key ] . localeCompare ( a [ key ] ) :
677
+ a [ key ] . localeCompare ( b [ key ] ) ;
678
+ } else { // Assuming numeric or other comparable types
679
+ return sort [ i ] . direction === 'desc' ?
680
+ ( b [ key ] - a [ key ] ) :
681
+ ( a [ key ] - b [ key ] ) ;
682
+ }
683
+ }
684
+ }
685
+ return 0 ;
686
+ } ) ;
687
+ }
688
+
689
+ function sortDataOld ( data , sort ) {
658
690
if ( ! Array . isArray ( sort ) )
659
691
sort = [ sort ]
660
692
for ( let i = 0 ; i < sort . length ; i ++ ) {
You can’t perform that action at this time.
0 commit comments