{"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-381429213", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 381429213, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQyOTIxMw==", "user": {"value": 222245, "label": "carlmjohnson"}, "created_at": "2018-04-15T18:54:22Z", "updated_at": "2018-04-15T18:54:22Z", "author_association": "NONE", "body": "I think I found a bug. I tried to sort by middle initial in my salaries set, and many middle initials are null. The next_url gets set by Datasette to:\r\n\r\nhttp://localhost:8001/salaries-d3a5631/2017+Maryland+state+salaries?_next=None%2C391&_sort=middle_initial\r\n\r\nBut then `None` is interpreted literally and it tries to find a name with the middle initial \"None\" and ends up skipping ahead to O on page 2.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379830529", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379830529, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTgzMDUyOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T17:28:47Z", "updated_at": "2018-04-09T17:28:47Z", "author_association": "OWNER", "body": "Another demo: https://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9/congress-age%2Fcongress-terms", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379803864", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379803864, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTgwMzg2NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T16:02:09Z", "updated_at": "2018-04-09T16:02:09Z", "author_association": "OWNER", "body": "This is now released in Datasette 0.15 https://github.com/simonw/datasette/releases/tag/0.15", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379791047", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379791047, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTc5MTA0Nw==", "user": {"value": 222245, "label": "carlmjohnson"}, "created_at": "2018-04-09T15:23:45Z", "updated_at": "2018-04-09T15:23:45Z", "author_association": "NONE", "body": "Awesome!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379634425", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379634425, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTYzNDQyNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T05:16:02Z", "updated_at": "2018-04-09T05:16:02Z", "author_association": "OWNER", "body": "I've merged this into master.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379608977", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379608977, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTYwODk3Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T02:22:59Z", "updated_at": "2018-04-09T02:22:59Z", "author_association": "OWNER", "body": "Here's a demo of the new clickable column headers: https://datasette-issue-189-demo-3.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&_sort_desc=last_name\r\n\r\n![2018-04-08 at 7 22 pm](https://user-images.githubusercontent.com/9599/38476370-3e62a60e-3b62-11e8-9d30-8dc6608133dd.png)\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379603156", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379603156, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTYwMzE1Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T01:41:22Z", "updated_at": "2018-04-09T01:41:22Z", "author_association": "OWNER", "body": "Actually I think I always want nulls last when ordering asc, nulls first when ordering desc.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379602690", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379602690, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTYwMjY5MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T01:37:03Z", "updated_at": "2018-04-09T01:37:03Z", "author_association": "OWNER", "body": "I'm going to split the following out into separate tickets:\r\n\r\n* Ability to sort by multiple columns e.g. `?_sort=name&sort_desc=age&_sort=height`\r\n* Ability to specify nulls last e.g. `?_sort_desc_nulls_last=age`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379602339", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379602339, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTYwMjMzOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T01:33:26Z", "updated_at": "2018-04-09T01:33:26Z", "author_association": "OWNER", "body": "Small bug: \"201 rows where sorted by sortable_with_nulls\" shouldn't have the word \"where\" in it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379595274", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379595274, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU5NTI3NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T00:24:37Z", "updated_at": "2018-04-09T00:29:46Z", "author_association": "OWNER", "body": "Another demo: https://datasette-issue-189-demo-2.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&_sort_desc=annual_salary\r\n\r\nhttps://datasette-issue-189-demo-2.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&last_name__exact=JOHNSON&_sort_desc=annual_salary", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379594529", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379594529, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU5NDUyOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-09T00:15:03Z", "updated_at": "2018-04-09T00:15:03Z", "author_association": "OWNER", "body": "Demo: senator tweets ordered by number of replies:\r\n\r\nhttps://datasette-issue-189-demo.now.sh/fivethirtyeight-2628db9/twitter-ratio%2Fsenators?_sort_desc=replies\r\n\r\nPage 2 (note that since Senators retweet things there are tweets with the same text/number-of-replies but retweeted by different senators that span the page break): https://datasette-issue-189-demo.now.sh/fivethirtyeight-2628db9/twitter-ratio%2Fsenators?_next=8556%2C121799&_sort_desc=replies\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379592393", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379592393, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU5MjM5Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-08T23:45:42Z", "updated_at": "2018-04-08T23:46:31Z", "author_association": "OWNER", "body": "Actually next page SQL when sorting looks more like this:\r\n\r\n```\r\nselect rowid, * from [alcohol-consumption/drinks]\r\nwhere \"country\" like :p0\r\nand (\r\n beer_servings > 111\r\n or (beer_servings = 111 and rowid > 190)\r\n)\r\norder by beer_servings, rowid limit 101\r\n```\r\n\r\nThe next page after row 190 with sortable value 111 should show either records that are greater than 111 or records that match 111 but have a greater primary key than the last one seen.\r\n\r\nhttps://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Balcohol-consumption%2Fdrinks%5D%0D%0Awhere+%22country%22+like+%3Ap0%0D%0Aand+%28%0D%0A++++beer_servings+%3E+111%0D%0A++++or+%28beer_servings+%3D+111+and+rowid+%3E+190%29%0D%0A%29%0D%0Aorder+by+beer_servings%2C+rowid+limit+101&p0=%25a%25", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379591062", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379591062, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU5MTA2Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-08T23:23:12Z", "updated_at": "2018-04-08T23:23:12Z", "author_association": "OWNER", "body": "To break this up into smaller units, the first implementation of this will only support a single `_sort` or `_sort_desc` querystring parameter.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379557982", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379557982, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU1Nzk4Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-08T15:16:49Z", "updated_at": "2018-04-08T15:16:49Z", "author_association": "OWNER", "body": "A note about views: a view cannot be paginated using keyset pagination because records returned from a view don't have a primary key - so there's no way to reliably distinguish between _next= records when the sorted column has duplicates with the same value.\r\n\r\nDatasette already takes this into account: views are paginated using offset/limit instead. We can continue to do that even for views that have been sorted using a `_sort` parameter.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379556774", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379556774, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU1Njc3NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-08T14:59:05Z", "updated_at": "2018-04-08T14:59:05Z", "author_association": "OWNER", "body": "A common problem with keyset pagination is that it can distort the \"total number of rows\" logic - every time you navigate to a further page the total rows count can decrease due to the extra arguments in the `where` clause. The `filtered_table_rows` value (see #194) calculated using `count_sql` currently has this problem.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-379555484", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 379555484, "node_id": "MDEyOklzc3VlQ29tbWVudDM3OTU1NTQ4NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-08T14:39:57Z", "updated_at": "2018-04-08T14:39:57Z", "author_association": "OWNER", "body": "I'm going to combine the code for explicit sorting with the existing code for _next= pagination - so even tables without an explicit sort order will run through the same code since they are ordered and paginated by primary key.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377547265", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377547265, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzU0NzI2NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-30T15:16:43Z", "updated_at": "2018-03-30T15:16:43Z", "author_association": "OWNER", "body": "I think this is the right incantation for a \"next\" link: https://datasette-column-sort-wip.now.sh/sortable-4bbaa6f?sql=select+*+from+sortable%0D%0Awhere+sortable+%3C%3D+94%0D%0Aand+%28%0D%0A++%28pk1+%3E+%27d%27%29%0D%0A++or%0D%0A++%28pk1+%3D+%27d%27+and+pk2+%3E+%27w%27%29%0D%0A%29%0D%0Aorder+by+sortable+desc%2C+pk1%2C+pk2%0D%0Alimit+7", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377546510", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377546510, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzU0NjUxMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-30T15:13:11Z", "updated_at": "2018-03-30T15:13:11Z", "author_association": "OWNER", "body": "Pushed some work-in-progress with failing unit tests here: https://github.com/simonw/datasette/commit/2f8359c6f25768805431c80c74e5ec4213c2b2a6\r\n\r\nHere's a demo: https://datasette-column-sort-wip.now.sh/sortable-4bbaa6f/sortable?_sort=sortable - note that the `_sort_desc` and `_sort_nulls_last` options aren't done yet, plus it doesn't correctly paginate (the `_next` tokens do not yet take sorting into account).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377462334", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377462334, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzQ2MjMzNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-30T07:06:21Z", "updated_at": "2018-03-30T07:06:21Z", "author_association": "OWNER", "body": "Maybe the answer here is that anything that's encoded in the next token is treated as >= with the exception of columns known to be primary keys, which are treated as >", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377460127", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377460127, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzQ2MDEyNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-30T06:51:29Z", "updated_at": "2018-03-30T06:51:52Z", "author_association": "OWNER", "body": "The problem is that our `_next=` pagination currently works based on a `>` - but for this case a `>=` for the value is needed combined with a `>` on the tie-breaker (which would be the `rowid` column).\r\n\r\nSo I think this is the right SQL:\r\n\r\n```\r\nselect rowid, * from [nfl-wide-receivers/advanced-historical]\r\nwhere career_ranypa >= -6.331167749 and rowid > 2736\r\norder by case when career_ranypa is null then 1 else 0 end, career_ranypa, rowid limit 11\r\n```\r\n\r\nhttps://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Bnfl-wide-receivers%2Fadvanced-historical%5D%0D%0Awhere+career_ranypa+%3E%3D+-6.331167749+and+rowid+%3E+2736%0D%0Aorder+by+case+when+career_ranypa+is+null+then+1+else+0+end%2C+career_ranypa%2C+rowid+limit+11\r\n\r\nBut how do I encode a `_next` token that means \">= X and > Y\"?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377459579", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377459579, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzQ1OTU3OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-30T06:47:52Z", "updated_at": "2018-03-30T06:47:52Z", "author_association": "OWNER", "body": "I'm not entirely sure how to get `_next=` pagination working against sorted collections when a tie-breaker is needed.\r\n\r\nConsider this data:\r\n\r\nhttps://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Bnfl-wide-receivers%2Fadvanced-historical%5D%0D%0Aorder+by+case+when+career_ranypa+is+null+then+1+else+0+end%2C+career_ranypa%2C+rowid+limit+11\r\n\r\n![2018-03-29 at 11 46 pm](https://user-images.githubusercontent.com/9599/38127549-790c8bd0-33ab-11e8-8d32-66f5d3847c8a.png)\r\n\r\nIf the page size was set to 9 rather than 11, the page divide would be between those two rows with the same value in the `career_ranypa` column. What would the `?_next=` token look like such that the correct row would be returned?\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377362466", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377362466, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzM2MjQ2Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-29T20:29:14Z", "updated_at": "2018-03-29T20:29:14Z", "author_association": "OWNER", "body": "Alternative idea: by default enable all sorting in the UI.\r\n\r\nIf a table has more than 100,000 rows disable sorting UI except for columns that have an index.\r\n\r\nAllow this to be overridden in metadata.json\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377055663", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377055663, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA1NTY2Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T22:14:53Z", "updated_at": "2018-03-28T22:14:53Z", "author_association": "OWNER", "body": "There is one other interesting option for auto-enabling/disabling sort: the inspect command could include data about column index presence and whether or not a column has any null values in it.\r\n\r\nThis would allow us to dynamically include a \"nulls last\" option but only for columns that contain at least one null.\r\n\r\nIt's quite a lot of additional engineering for a very minor feature though, so I think I'll punt on that for the moment.\r\n\r\nWe may find that the _group_count feature can benefit from column value statistics later on though.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377054358", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377054358, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA1NDM1OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T22:09:25Z", "updated_at": "2018-03-28T22:09:25Z", "author_association": "OWNER", "body": "I'm tempted to put these verbose sorting options inline in the page HTML but have them in the table footer so they don't clog up the top half of the page with uninteresting links - then use JavaScript to hoik them out into a dropdown menu attached to each column header.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377050461", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377050461, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA1MDQ2MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T21:55:14Z", "updated_at": "2018-03-28T22:06:30Z", "author_association": "OWNER", "body": "I think there are actually four kinds of sort order we need to support;\r\n\r\n* ascending\r\n* descending\r\n* ascending, nulls last\r\n* descending, nulls last\r\n\r\nIt looks like [-blah] is a valid SQLite table name, so mark I descending with a hyphen prefix isn't good.\r\n\r\nInstead, maybe this:\r\n\r\n ?_sort_asc=col1&_sort_desc_nulls_last=col2\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377052634", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377052634, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA1MjYzNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T22:03:16Z", "updated_at": "2018-03-28T22:03:16Z", "author_association": "OWNER", "body": "In terms of user interface: the obvious place to put this is as a drop down menu on the column headers.\r\n\r\nThis also means the UI can support combined sort orders. Assuming you are already sorted by county descending and you select the candidate column header, the options could be:\r\n\r\n* sort all by candidate\r\n* sort all by candidate, descending\r\n* sort by county descending, then by candidate\r\n* sort by county descending, then by candidate descending", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377051018", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377051018, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA1MTAxOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T21:57:20Z", "updated_at": "2018-03-28T22:00:17Z", "author_association": "OWNER", "body": "I'd like to continue to support _next=token pagination even for custom sort orders.\r\n\r\nTo do that I should include rowid (or general primary key) as the tie breaker on all sorts so I can incorporate that it into the _next= token.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-377049625", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 377049625, "node_id": "MDEyOklzc3VlQ29tbWVudDM3NzA0OTYyNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T21:52:05Z", "updated_at": "2018-03-28T21:52:05Z", "author_association": "OWNER", "body": "This is a better pattern as you don't have to pick a minimum value:\r\n\r\n ORDER BY CASE WHEN SOMECOL IS NULL THEN 1 ELSE 0 END, SOMECOL", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-376986668", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 376986668, "node_id": "MDEyOklzc3VlQ29tbWVudDM3Njk4NjY2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T18:21:53Z", "updated_at": "2018-03-28T18:21:53Z", "author_association": "OWNER", "body": "Might have to do something special to get sort-by-nulls-last: https://stackoverflow.com/questions/12503120/how-to-do-nulls-last-in-sqlite\r\n\r\n order by ifnull(column_name, -999999)\r\n\r\nWould need to figure out a smart way to get the default value - maybe by running a min() or max() against the column first?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-376983741", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 376983741, "node_id": "MDEyOklzc3VlQ29tbWVudDM3Njk4Mzc0MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T18:12:35Z", "updated_at": "2018-03-28T18:12:35Z", "author_association": "OWNER", "body": "I think this can work with a `?_sort=xxx` parameter - and `?_sort=-xxx` to sort in the opposite direction.\r\n\r\nI'd like to support \"sort by X descending, then by Y ascending if there are dupes for X\" as well. Two ways that could work:\r\n\r\n`?_sort=-xxx,yyy`\r\n\r\nOr...\r\n\r\n`?_sort=-xxx&_sort=yyy`\r\n\r\nThe second option is probably better in that it makes it easier for columns to have a comma in their name.\r\n\r\nIs it possible for a SQLite column to start with a `-` character?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/189#issuecomment-376981291", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/189", "id": 376981291, "node_id": "MDEyOklzc3VlQ29tbWVudDM3Njk4MTI5MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-03-28T18:06:08Z", "updated_at": "2018-03-28T18:06:08Z", "author_association": "OWNER", "body": "Given how unlikely it is that this will pose a real problem I think I like option 1: enable sort-by-column by default for all tables, then allow power users to instead switch to explicit enabling of the functionality in their `metadata.json` if they know their data is too big.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309471814, "label": "Ability to sort (and paginate) by column"}, "performed_via_github_app": null}