Sort != Sort (Gallery & Grid Views)
Describe the bug When sorting based on a Lookup field, the sorting is not correct.
To Reproduce
- Create a table
- create a second table
- Link the 2 tables
- Create a lookup column in table 2 that pulls values from table 1
- Create a gallery view
- Sort the view based on the lookup column
Expected behavior The values are sorted naturally
Screenshots
** Client (please complete the following information):**
- OS: EndeavourOS (Arch Linux)
- Browser: Vivaldi 7.9.3970.45 (Official Build) (64-bit)
- Version Teable App version: 0.5.0-alpha+1.10.0-build.1267
Platform (Please tell us which deployment version you are using) docker compose
Additional context N/A
Can i work on this issue I think the issue comes from how lookup values are being handled during sorting. Right now it looks like we might be sorting on raw/internal values instead of what’s actually displayed.
A couple of things that could help fix this:
Resolve the lookup values before sorting so we’re comparing the actual displayed data, not IDs or references. Since lookup fields can return arrays, normalize them into something comparable — either take the first value or join them into a string. Use a proper comparator depending on the type
@Ingole712521 here's the community link where troubleshooting occurred and a workaround was put in place; https://community.teable.ai/t/sorting-of-lookup-field-values-does-not-seem-to-work/189/17
To summarize, sort follows the order of the list of single/multi select options, and not alphabetically.
@ScriptJunky thank you for the report and for following up in the community thread.
As discussed here, sorting single-select and multi-select values follows the option order defined in the source field, not alphabetical order, and lookup fields inherit that order: https://community.teable.ai/t/sorting-of-lookup-field-values-does-not-seem-to-work/189/17
The workaround you shared, sorting by a formula/text field derived from the lookup value and hiding that helper field, is the right path for alphabetical sorting today. I am closing this issue because the reported behavior is the current sorting model, and we are not treating it as a bug fix. The feature suggestion for automatic select-option sorting has been noted from the community discussion.