Set column types in a listview control for proper sorting

Hi. I've noticed that in the latest betas, the Script Management window now has a new "Installed" column. Thanks for that!
And you can also sort by that column based on the date. Is that a custom control or a standard Windows one?

Would it be possible to bring that same ability to script dialog listview controls, so they can sort based on the column's content type? Right now, when sorting, everything is treated as text.

I'm imagining something like this:
Being able to define in a Map the column index as the key and the expected content type as the value (date, number, text, etc.). Then, when the user sorts a column, Opus could apply the sorting logic based on that content type.

Thanks for considering it.

It's a Windows control, but we sort it ourselves. Windows list controls can only natively sort by name/string.

To get the same thing in a script, set the control to not sort its items, then add them in the order you want them. The control will then preserve that order.

That also lets you sort in custom ways, or with data types Opus doesn't know about on its side.

Edit: I'm not sure if there's a way for scripts to know when the sort column header is clicked, which you'd need to react to in order to re-sort the list by different columns. We could probably add a msg/event for that if it's needed.

Afaik there's not.
Wouldn't it be faster/better to port or perhaps include a method for sorting columns by type? Now that I think about it, those columns are actually objects, so perhaps adding a "type" property would make sense for sorting purposes.

What if it's a custom type Opus has no knowledge of? I think it would have to be up to the script to sort things, at least in general. Maybe there could be helpers for sorting by common types like dates.

I guess we could have a mechanism for sorting where the script provides a function name that would act as a callback to compare two list items, although I'm not sure what the performance would be like jumping in and out of the script multiple times like that.

In that case, it would simply sort it as text I think. Only known types would be supported (number, date, size, text). Nothing too fancy. Maybe apart from set the column's type, the values (as text) would probably need to be formatted accordingly.

That's what I thought too when Leo suggested letting the script implement its own sorting. It's possible, but I imagine it would be slower than a native method (and more complicated too).