Potential bug: Table sorting occasionally not working correctly

See screenshot above. Table is supposedly sorted by Repartidor column (driver), as indicated by the black dash in the table header, but the results are clearly not sorted.
Column type is set to String.
This seems to be happening non-deterministically: sometimes it works as expected, sometimes it doesn't.

@maurizio My first thought was to ask about the column type but you beat me to it. Have you seen this issue in any other apps or data sets?

Some of our employees mentioned they’ve seen this bug in another dashboard while trying to sort this same driver / repartidor column. What’s weird is I couldn’t replicate the bug before and now it seems to be working fine again. I only saw it last night, in both edit and view modes and with column type set to string and default

FYI the table data comes from a REST GET query, and the driver column is a plain string. i.e. table data is something like [{id: 46, driver: 'Hermilo', ...}, {id: 26, driver: 'Jose'}, .... ].

Saw this issue again on the same app, different column: a non-null value is displayed between null values. The problem persists even after changing null values to the empty string.

I think the issue is when there’s a null value. I can reproduce the bug by following the steps below:

  1. Create new blank app
  2. Delete preset query1
  3. Add a table. Gets prepopulated with dummy data.
  4. Change a value in the table data null (in screenshot above, I changed Jason Response's name to null . Sorting no longer works

@maurizio Wow, thank you for the thorough repro! The sorting algorithm might not have error handling for a null value. I’ll get this over to engineering and update here.

Any updates on this reported problem? I’m seeing the same thing.

Hey Laura!

I looked into this with Will, it looks like setting the column type to String in this case fixes the sorting behavior! The bug previously affected String type columns, but now it looks to have resurfaced just for the Default column type

1 Like

Hi @alex-w ,
I have an issue with sorting but in my case my column has a mapper on it, i make the Column type to boolean because that's what i want to display, but my original value for the column is a string. When i am sorting it out, i believe the sorting is using the string value not the value i displayed on the table.

Any thoughts? Thanks!

Hi Vincent! As a super unhelpful note, mappers are basically just frontend and sorting is backend, so when you sort a table, it sorts based on the true data rather than the mapped data.

Would you be open to converting this data into a boolean in a JS transformer before showing it in the table? That way you could sort the boolean data since the data is coming from the "backend"! Here's a quick example:

return Object.assign({{query1.data}}, {id: {{formatDataAsArray(query1.data)}}.map(row_obj => row_obj.id % 2 == 0) })

1 Like

I am facing same issue with sorting,
Also It's not showing proper data when I used Column type = Date Time
The time is showing incorrect when I use Column type = Auto. By using Column type = Auto datetime show correct but sorting is not working proper.

My retool version is 3.13.0