File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 302302 }
303303
304304 if ( Selector ) {
305+ // let selectors = Selector.split(/,(?![^()]*\))/g);
305306
306307 let selectors = Selector . split ( ',' ) ;
307308 for ( let j = 0 ; j < selectors . length ; j ++ ) {
654655 return true
655656 }
656657
658+
657659 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 ) {
658690 if ( ! Array . isArray ( sort ) )
659691 sort = [ sort ]
660692 for ( let i = 0 ; i < sort . length ; i ++ ) {
You can’t perform that action at this time.
0 commit comments