@@ -207,7 +207,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
207
207
}
208
208
}
209
209
210
- function naturalSortAscending ( a , b ) {
210
+ const isPunctSort = th . classList . contains ( "punct-sort" ) ;
211
+ const isAlphaSort = th . classList . contains ( "alpha-sort" ) ;
212
+ function sortAscending ( a , b ) {
211
213
if ( a . includes ( `${ fillValue } #` ) ) {
212
214
return 1 ;
213
215
} else if ( b . includes ( `${ fillValue } #` ) ) {
@@ -216,13 +218,13 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
216
218
return a . localeCompare (
217
219
b ,
218
220
navigator . languages [ 0 ] || navigator . language ,
219
- { numeric : true , ignorePunctuation : true }
221
+ { numeric : ! isAlphaSort , ignorePunctuation : ! isPunctSort }
220
222
) ;
221
223
}
222
224
}
223
225
224
- function naturalSortDescending ( a , b ) {
225
- return naturalSortAscending ( b , a ) ;
226
+ function sortDescending ( a , b ) {
227
+ return sortAscending ( b , a ) ;
226
228
}
227
229
228
230
function clearArrows ( arrowUp = "▲" , arrowDown = "▼" ) {
@@ -243,27 +245,27 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
243
245
244
246
function sortColumn ( sortDirection ) {
245
247
columnData . sort ( sortDirection , {
246
- numeric : true ,
247
- ignorePunctuation : true ,
248
+ numeric : ! isAlphaSort ,
249
+ ignorePunctuation : ! isPunctSort ,
248
250
} ) ;
249
251
}
250
252
251
253
if ( timesClickedColumn === 1 ) {
252
254
if ( desc ) {
253
255
changeTableArrow ( arrowDown ) ;
254
- sortColumn ( naturalSortDescending ) ;
256
+ sortColumn ( sortDescending ) ;
255
257
} else {
256
258
changeTableArrow ( arrowUp ) ;
257
- sortColumn ( naturalSortAscending ) ;
259
+ sortColumn ( sortAscending ) ;
258
260
}
259
261
} else if ( timesClickedColumn === 2 ) {
260
262
timesClickedColumn = 0 ;
261
263
if ( desc ) {
262
264
changeTableArrow ( arrowUp ) ;
263
- sortColumn ( naturalSortAscending ) ;
265
+ sortColumn ( sortAscending ) ;
264
266
} else {
265
267
changeTableArrow ( arrowDown ) ;
266
- sortColumn ( naturalSortDescending ) ;
268
+ sortColumn ( sortDescending ) ;
267
269
}
268
270
}
269
271
}
@@ -355,7 +357,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
355
357
sortDataAttributes ( visibleTableRows , columnData ) ;
356
358
}
357
359
358
- const isFileSize = th . classList . contains ( "file-size" ) ;
360
+ const isFileSize = th . classList . contains ( "file-size-sort " ) ;
359
361
if ( isFileSize ) {
360
362
sortFileSize ( visibleTableRows , columnData ) ;
361
363
}
0 commit comments