@@ -122,6 +122,32 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
122122 }
123123 }
124124
125+ function sortByRuntime ( tableRows , columnData ) {
126+ for ( let [ i , tr ] of tableRows . entries ( ) ) {
127+ const regexMinutesAndSeconds = / ^ ( \d + m ) \s ? ( \d + s ) $ / i;
128+ let columnOfTd = tr
129+ . querySelectorAll ( "td" )
130+ . item ( columnIndex ) . textContent ;
131+ let match = columnOfTd . match ( regexMinutesAndSeconds ) ;
132+ let minutesInSeconds ,
133+ seconds ,
134+ timeinSeconds = [ 0 , 0 , 0 ] ;
135+ if ( match ) {
136+ const regexMinutes = match [ 1 ] ;
137+ if ( regexMinutes ) {
138+ minutesInSeconds = Number ( regexMinutes . replace ( "m" , "" ) ) * 60 ;
139+ }
140+ const regexSeconds = match [ 2 ] ;
141+ if ( regexSeconds ) {
142+ seconds = Number ( regexSeconds . replace ( "s" , "" ) ) ;
143+ }
144+ timeinSeconds = minutesInSeconds + seconds ;
145+ }
146+ columnData . push ( `${ timeinSeconds } #${ i } ` ) ;
147+ columnIndexAndTableRow [ columnData [ i ] ] = tr . innerHTML ;
148+ }
149+ }
150+
125151 let [ timesClickedColumn , columnIndexesClicked ] = [ 0 , [ ] ] ;
126152
127153 function rememberSort ( timesClickedColumn , columnIndexesClicked ) {
@@ -152,6 +178,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
152178 tableRows,
153179 columnData,
154180 isFileSize,
181+ isTimeSort,
155182 isDataAttribute,
156183 colSpanData,
157184 colSpanSum,
@@ -171,7 +198,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
171198 if ( isFileSize ) {
172199 fileSizeColumnTextAndRow [ columnData [ i ] ] = tr . innerHTML ;
173200 }
174- if ( ! isFileSize && ! isDataAttribute ) {
201+ if ( ! isFileSize && ! isDataAttribute && ! isTimeSort ) {
175202 columnData . push ( `${ tdTextContent } #${ i } ` ) ;
176203 columnIndexAndTableRow [ `${ tdTextContent } #${ i } ` ] = tr . innerHTML ;
177204 }
@@ -307,6 +334,11 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
307334 sortFileSize ( visibleTableRows , columnData ) ;
308335 }
309336
337+ const isTimeSort = th . classList . contains ( "runtime-sort" ) ;
338+ if ( isTimeSort ) {
339+ sortByRuntime ( visibleTableRows , columnData ) ;
340+ }
341+
310342 const isRememberSort = sortableTable . classList . contains ( "remember-sort" ) ;
311343 if ( ! isRememberSort ) {
312344 rememberSort ( timesClickedColumn , columnIndexesClicked ) ;
@@ -320,6 +352,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
320352 columnData,
321353 isFileSize,
322354 isDataAttribute,
355+ isTimeSort,
323356 colSpanData,
324357 colSpanSum,
325358 } ;
0 commit comments