Sortable Tables on the TBP Forum?

I’d like to request that the admins look into adding sortable tables to the forum. TBH, I’m not sure how much use this feature would get, but it would be fun to play with and could be a boon to folks publishing tabular information. Anyway, ChatGPT sez:

:compass: Option 1 — Use a lightweight JS library (works on GitHub Pages, most static sites)

This is the most common and portable approach.

:white_check_mark: Minimal setup with Tablesort

Add this to your page (or site template):

Then just write your Markdown table normally:

Name Age Score
Alice 30 88
Bob 25 95
Carol 27 91

:backhand_index_pointing_right: When rendered, click column headers to sort.

Why this is nice

No changes to your Markdown

Works on GitHub Pages (Jekyll, etc.)

Very small and fast

:compass: Option 4 — Discourse (special case)

Discourse does NOT support sortable tables by default.

Options:

1. Admin plugin (best if you control the forum)

  • discourse-data-explorer (not exactly for tables)
  • custom theme component with Tablesort

2. Theme component approach

If you can add theme JS:

api.decorateCookedElement((elem) => {
elem.querySelectorAll(“table”).forEach(t => new Tablesort(t));
});

:backhand_index_pointing_right: This gives sorting across all posts automatically.

Careful Reader may have noticed that the JS code in my previous post isn’t working. ChatGPT sez:

It looks like Discourse strips or blocks JavaScript in normal posts, so this approach won’t work unless the forum admins add sortable-table support at the theme/plugin level.