Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

15
  • 8
    You would need Javascript to make it work and it typically only makes sense for tables with many rows. There could be a default sort order and users could sort by other columns as well. Typically upwards and downwards pointing triangles are used for that in web pages. Wikipedia for example has this feature. Teams users would probably like it a lot. Commented Nov 24, 2020 at 20:20
  • 20
    What's the idea behind this? Should this be a tool for the post author to sort a table when writing a post? Or is this supposed to be something for a reader so they can sort data according to their needs?
    – Ham Vocke StaffMod
    Commented Nov 25, 2020 at 16:24
  • 33
    @HamVocke for the reader. Same as on Wikipedia. Commented Nov 25, 2020 at 18:36
  • 20
    We've got prior art in Stacks, our design system. Maybe we can do something similar here. It's an interesting proposal and we'll have to think this through.
    – Ham Vocke StaffMod
    Commented Nov 25, 2020 at 18:40
  • 2
    @HamVocke I can imagine it could be both. Even though the content creator could in principle create any desired sorting manually, it might be convenient to use the feature once it's there to also allow the post author to specify a default sorting. And once it's there one could also allow the reader to re-sort. Once you are there, you also might want to filter. Data tables comes to my mind. Commented Nov 26, 2020 at 10:31
  • 35
    We've discussed this idea with a bunch of folks today. We think this is harder to get right than it seems initially. Sorting table data will inevitably lead to follow-up questions: What about sorting multiple columns? What about different sorting methods (dates, integers, ...)? I agree that this is a nice feature but it takes more effort to flesh this out properly.
    – Ham Vocke StaffMod
    Commented Nov 30, 2020 at 17:10
  • 8
    @HamVocke Thanks for the feedback. I agree that a perfect solution is very hard to achieve. In your shoes I'd simply imitate Wikipedia's sortable table. Commented Nov 30, 2020 at 17:13
  • 8
    I love the ability to sort tables in Wikipedia; and I've updated a few articles to allow tables with "strange" data to sort correctly, and there are unfortunately lots of workarounds to sort things nicely. en.wikipedia.org/wiki/Help:Sorting I think there are few cases in SO where I would have benefitted from sorting a table. Commented Dec 4, 2020 at 17:03
  • 4
    Why don't we just do exactly what Wikipedia has? The code is not hard to access and is easy to imitate. Commented Dec 6, 2020 at 17:33
  • 12
    If sorting is ever introduced, please use a stable sorting algorithm (one which preserves previous order in case of ties) - this is an intuitive way to do multiple column sorting.
    – jaskij
    Commented Dec 8, 2020 at 18:44
  • 10
    I can't think of a single use case where this would be useful? If someone is adding so much data that sorting is useful, then that data is probably detrimental to the question being asked. Seems like an idea for ideas sake. Given the difficulty of the task I'd say there are better things to fix
    – Liam
    Commented Dec 9, 2020 at 10:02
  • 1
    @Liam easy to do client side. Tables can also be used in answers. No need for a table to be large for sorting to be useful. My table is an example where sorting would be useful. Commented Dec 9, 2020 at 10:07
  • 1
    @Liam I'd use the table for a question on the accuracy of speech recognition apis. Linguistics SE, or DS. Commented Dec 9, 2020 at 10:12
  • 1
    Right ok, I think I'm focusing on the list of names in Excel. I get that now, I still think it's niche TBH. I guess it depends on how this feature is going to get used and I don't think we know that right now.
    – Liam
    Commented Dec 9, 2020 at 10:13
  • 5
    @HamVocke "What about sorting multiple columns?" The easiest way to support this is by using a stable sort (and IMO that is the correct way to do column sorting; the non-stable variant is wrong). Then, if you want to sort by (Firstname, Lastname), you can sort the firstname column, then sort the lastname column.
    – Justin
    Commented Dec 12, 2020 at 18:43