How do I sort by raw value, but display a more human readable value?

I have a column that list file sizes. The raw values are in bytes, but that’s not very easy to read. I have a function that displays them nicely in KB, MB, etc., but that really screws up the sorting. How can I reconcile the two?

Can you share some screenshots of the way you display them using the function and the bindings you use?

Here’s the function:
image

And here’s the binding:
image

image

Think of it as similar to a date. The date value doesn’t change, just the way it’s displayed. I actually tried to change it to a date and use custom JS to format it, but it said it was a disallowed value.

Hey @bobbintb, I think the table widget is always going to sort on the same value you see in the UI. So if you’re viewing the human-readable version and sort that column, it will always sort it as text. And the raw value will sort as a number. I don’t think there’s a way to make the human-readable column sort by the raw size.

You could turn off table sorting though, and use lodash _.orderBy() to keep the data sorted by the raw size, but only display the human-readable version.
https://lodash.com/docs/4.17.15#orderBy