This is hard to describe. I hope the example at https://commons.wikimedia.org/w/index.php?title=Commons:Sandbox&oldid=75246712 explains, what I want to say.
As far as I understand currently the code looks for the header row with most cells, to decide which cells can be clicked to sort the table (function buildHeaders). But it should look at the row with the most *columns*, i.e. count cells after considering rowspan (which is somewhat contrary to bug 31420).
With a header like
{| class="wikitable sortable"
!rowspan="2" | Jahrrowspan="2" | Gewinnerrowspan="2" | Nationalität!!colspan=5|Score
- |
! R1 R2 R3 R4 Total
- |
not only the columns labeled R1 to Total (in the second row) should be sortable, but also the first three columns, which span over two rows and currently aren't considered as there cells belong to the first row.
My example shows a workaround for this:
{| class="wikitable sortable"
! style="border-bottom: hidden;" | style="border-bottom: hidden;" | style="border-bottom: hidden;" | !! colspan=5|Score
- |
! Jahr Gewinner Nationalität R1 R2 R3 R4 !! Total
- |
which just adds an invisible cell in the first row, and moves the header in the second row. But the text should be centered vertically, and the whole header (both rows) should be clickable.
Version: 1.22.0
Severity: enhancement
URL: https://commons.wikimedia.org/w/index.php?title=User:Schnark/tablesorter&oldid=95146565