@@ -483,10 +483,11 @@ class BootstrapTable {
483
483
}
484
484
485
485
initSort ( ) {
486
- let name = this . options . sortName
486
+ const name = this . options . sortName
487
487
const order = this . options . sortOrder === 'desc' ? - 1 : 1
488
488
const index = this . header . fields . indexOf ( this . options . sortName )
489
489
let timeoutId = 0
490
+
490
491
if ( index !== - 1 ) {
491
492
if ( this . options . sortStable ) {
492
493
this . data . forEach ( ( row , i ) => {
@@ -503,18 +504,22 @@ class BootstrapTable {
503
504
] )
504
505
} else if ( this . options . groupBy === true && this . options . groupByField !== '' ) {
505
506
const groupedData = { }
507
+
506
508
this . data . forEach ( item => {
507
- const groupKey = Utils . getItemField ( item , this . options . groupByField , this . options . escape ) ;
509
+ const groupKey = Utils . getItemField ( item , this . options . groupByField , this . options . escape )
510
+
508
511
if ( ! groupedData [ groupKey ] ) {
509
512
groupedData [ groupKey ] = [ ]
510
513
}
511
514
groupedData [ groupKey ] . push ( item )
512
- } ) ;
515
+ } )
513
516
const sortedGroups = Object . keys ( groupedData ) . map ( groupKey => {
514
517
const group = groupedData [ groupKey ]
518
+
515
519
Utils . sort ( name , order , index , group , this . header , this . options )
516
520
return group
517
- } ) ;
521
+ } )
522
+
518
523
this . data = [ ] . concat ( ...sortedGroups )
519
524
} else {
520
525
Utils . sort ( name , order , index , this . data , this . header , this . options )
0 commit comments