{"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709571143", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709571143, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTU3MTE0Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T20:25:35Z", "updated_at": "2020-10-15T20:25:35Z", "author_association": "OWNER", "body": "`cast(nullif(colname, '') as real)` can fix this - it will treat `''` the same as `null`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709539257", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709539257, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUzOTI1Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T19:19:29Z", "updated_at": "2020-10-15T19:34:07Z", "author_association": "OWNER", "body": "Urgh this isn't going to work. `%7E~%7E` gets decoded as `~~~` so I wouldn't be able to tell the difference.\r\n\r\nI could use double-percentage-encoding here instead. I feel like there's a simpler solution that I'm missing (and that may well be in use within Datasette already, I'm not doing great thinking this morning).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709505147", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709505147, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUwNTE0Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T18:18:45Z", "updated_at": "2020-10-15T18:50:50Z", "author_association": "OWNER", "body": "This needs querystring parameter design. Some options:\r\n\r\n* `?_sort_clause=cast(mycol+as+integer)` and `?_sort_clause_desc=cast(mycol+as+integer)` - allowing any expression. This would need to be disabled if arbitrary SQL was turned off, similar to the restrictions on `?_where=`.\r\n* `?_sort_numeric=mycol` and `?_sort_numeric_desc=mycol` - this would cast to `real` which would work on integer values as well. It could be allowed even when arbitrary SQL was disabled.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709525082", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709525082, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUyNTA4Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T18:51:59Z", "updated_at": "2020-10-15T18:51:59Z", "author_association": "OWNER", "body": "This is enough of a design to build a working prototype.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709509635", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709509635, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUwOTYzNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T18:24:57Z", "updated_at": "2020-10-15T18:24:57Z", "author_association": "OWNER", "body": "This does feel like a weird plugin hook just because there aren't really THAT many different use-cases that plugins could solve. The ones I can think of are:\r\n\r\n- Sort numeric\r\n- Sort by parsed date\r\n- Sort by FTS rank\r\n\r\nCould this work if I just allow `_sort_clause=`?\r\n\r\nOne possible solution for the no-arbitrary-SQL case: users can define sort orders in `metadata.json/yml`. So if you want to enable sort-by-distance without enabling arbitrary SQL you could add something like this:\r\n\r\n```yaml\r\ndatabases:\r\n mydb:\r\n tables:\r\n museums:\r\n sort_clause: bm25(fts)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709510422", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709510422, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUxMDQyMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T18:26:25Z", "updated_at": "2020-10-15T18:26:25Z", "author_association": "OWNER", "body": "There's something interesting about figuring out which sort options should be offered in the column actions menu.\r\n\r\nTwo options:\r\n\r\n- Try to detect if a text column is all-integers or all-floats, either by scanning the entire table (if it's small enough) or by scanning the first X rows, where X might be the size of the first page or maybe the first 1,000 or similar.\r\n- Could also let users define this in `metadata.yml` for the table.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709511399", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709511399, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUxMTM5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T18:28:09Z", "updated_at": "2020-10-15T18:28:09Z", "author_association": "OWNER", "body": "The simplest solution would be for Python code to scan all of the visible values on the current page and show the column action for \"sort by this numeric\" based purely on that. I already do that in the JavaScript for \"are there any blank values in the first page?\" here:\r\n\r\nhttps://github.com/simonw/datasette/blob/4f7c0ebd85ccd8c1853d7aa0147628f7c1b749cc/datasette/static/table.js#L106-L118\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": 657572753, "label": "?sort=colname~numeric to sort by by column cast to real"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/894#issuecomment-709531343", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/894", "id": 709531343, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTUzMTM0Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T19:03:12Z", "updated_at": "2020-10-15T19:03:12Z", "author_association": "OWNER", "body": "The Sort by `