dessalines
dessalines

Reputation: 7372

Is there any way to make markdown tables sortable?

I'd like to write my table in markdown text, but allow it to be sortable on github after its been rendered(simple asc/desc sorting by clicking on the column header.

Any way to do this?

Upvotes: 59

Views: 28258

Answers (3)

VonC
VonC

Reputation: 1324318

A possible alternative is offered with GitLab 15.4 (September 2022):

Sortable, filterable data-driven tables in Markdown

Working with tables in Markdown can be a bit cumbersome. Not only is it difficult to figure out the correct number of pipes and empty cells, but the table output is static when you save your document. If you have to sort the table by the third column in an ascending order, you end up rewriting the whole thing.

Now you can insert data-driven tables using JSON syntax as follows:

In the rendered table, you can also enable:

  • Sorting for specific fields using "sortable": true
  • Dynamic filtering of data using "filter" : true

Now it’s as simple as a click when you have to re-sort that 100-row table and as easy as a web search when you have to find that one issue reference lost in a sea of nearly identical URLs.

GitLab sortable table

See Documentation and Merge Request.

Upvotes: 11

Rob Bednark
Rob Bednark

Reputation: 28152

There are some Chrome plugins that do this, including HTML Table Auto Sort that I've used that toggles ascending/descending sort when clicking on a column header.

Upvotes: 1

Bertrand Martel
Bertrand Martel

Reputation: 45382

Table sort is not supported in Github flavored markdown but one alternative is to use user script such as Github Sort Content

It's very easy to install, for instance from Chrome :

Then tables from github.com markdown pages can be sorted like :

enter image description here

Upvotes: 40

Related Questions