Skip to content

Facets sort alphabetically? #1908

Answered by simonw
oscarchic asked this question in General
Discussion options

You must be logged in to vote

It's not at the moment, but this is an interesting feature idea.

Right now you can achieve this using a custom SQL query, for example for the list of states on https://congress-legislators.datasettes.com/legislators/legislator_terms?_facet=state&_facet_size=max

You can run this:

https://congress-legislators.datasettes.com/legislators?sql=select+state%2C+count%28*%29+from+legislator_terms+group+by+state+order+by+state

select
  state,
  count(*)
from
  legislator_terms
group by
  state
order by
  state

Or if you want to be able to click a link to view the results by state:

select
  state,
  count(*),
  'https://congress-legislators.datasettes.com/legislators/legislator_terms?state=' || state 

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by simonw
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants