Skip to content

Sorting support for wt list #3922

Description

@everag

Feature Request: Configurable row sorting for wt list

Summary

Allow configuring the sort order of rows displayed by wt list.

The list.columns configuration already provides control over which columns are displayed and their order. It would be useful to have equivalent control over the ordering of the rows.

Motivation

I use a custom wt list layout with the worktree path displayed before the branch:

[list]
columns = ["path", "branch", "status", ...]

For this layout, I'd also like the rows to be sorted by path, so that the listing corresponds naturally to the physical organization of my worktrees.

Currently, the row ordering appears to be determined internally, with no configuration option to change it.

Proposed configuration

Something along the lines of:

[list]
columns = ["path", "branch", "status", ...]
sort = ["path"]

Potentially supporting multiple sort keys:

[list]
sort = ["path", "branch"]

And optionally descending order:

[list]
sort = [
  { column = "path", order = "asc" },
  { column = "age", order = "desc" },
]

The exact syntax is up to the implementation; the important part is allowing users to choose the primary (and optionally secondary) sort columns.

Use case

For example, with:

~/repo
~/repo.feature-a
~/repo.feature-b
~/repo.fix-c

I'd like wt list to display those worktrees in path order while retaining the normal table rendering and all of the existing status information.

This would be particularly useful now that list.columns supports customizable column selection and ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions