simonw / simonw/datasette

Ability to sort by more than one column

Open
#197 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
11.5k
Forks
904
Avg merge
4d 17h
Merged PRs (30d)
18

Description

Split off from #189.

I'd like to support "sort by X descending, then by Y ascending if there are dupes for X" as well. Suggested syntax for that:

?_sort_desc=X&_sort=Y

we currently only allow one argument to be sent. We should allow as many arguments as there are columns, for example:

?_sort=department&_sort_desc=precinct&_sort=age&_sort_desc=size

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the issue. Start by locating the current handling of the single _sort and _sort_desc query arguments, then trace how they become the database ordering. Done means supporting repeated sort arguments with the documented precedence and covering the example ordering behavior with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
api, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.