Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Sort MD TablesNew to Visual Studio Code? Get it now.
Sort MD Tables

Sort MD Tables

Orlando Calvo

|
2 installs
| (0) | Free
Sort Markdown table rows from clickable column-header hovers, including prioritized multi-column sorting.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Sort MD Tables

Sort Markdown tables without leaving the editor or converting your document to another format.

Usage

  1. Open a Markdown document containing a pipe table.
  2. Hover over any table header.
  3. Choose Ascending or Descending in the hover.

The extension rewrites only the body-row range. Header text, the delimiter row, cell spacing, links, inline code, and other row formatting remain intact.

Multi-column sorting

Sort MD Tables follows the established data-grid sort model:

  • A column can be ascending, descending, or unsorted.
  • Sorting a new column adds it as the next tie-breaker.
  • Existing sort rules retain their priority. For example, sort Year first and Month second to group by year, then month.
  • Clear one column's rule from that header, or use Clear all to restore the row order captured before the first sort.

The hover shows the active priority as 1. Year ↑ · 2. Month ↓. This is the same always-on multi-sort interaction documented by MUI X Data Grid, adapted to VS Code hover actions.

Comparison behavior

  • Columns whose non-empty cells are all plain numbers use numeric comparison, including signs, decimals, and thousands separators.
  • Other columns use case-insensitive natural alphanumeric comparison, so Item 2 sorts before Item 10.
  • Empty cells sort before non-empty cells in ascending order.
  • Equal values preserve the pre-sort row order.

You can also run the four Sort MD Tables commands from the Command Palette while the cursor is in a table header.

Supported tables

The extension targets standard Markdown pipe tables with a header delimiter row containing at least three dashes per column. Leading and trailing pipes are optional. Escaped pipes and pipes inside inline-code spans are recognized as cell content.

Multiline cells and HTML <table> blocks are not Markdown pipe tables and are not changed.

Sort state and safety

Sorting changes the Markdown document and participates in VS Code's normal Undo history. Active multi-sort rules and the pre-sort row order are held in memory; they reset when the table body is manually edited or VS Code restarts. The already-sorted Markdown remains exactly as saved.

Sort MD Tables makes no network requests, collects no telemetry, and works in untrusted and virtual workspaces.

Development

npm install
npm run check
npm run test:integration
npm run package:vsix

Press F5 in VS Code to launch an Extension Development Host.

License

MIT License. The full text is included in LICENSE.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft