Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow sorting by a 'Time' column #186

Open
MaximilianSoerenPollak opened this issue Nov 2, 2024 · 1 comment
Open

Feature Request: Allow sorting by a 'Time' column #186

MaximilianSoerenPollak opened this issue Nov 2, 2024 · 1 comment

Comments

@MaximilianSoerenPollak
Copy link
Contributor

Currently sorting (in either direction) is available by sorting strings or numbers.
I think a usecase that probably will happen also quite a bit would be to sort by a column that is a 'time.Time'.

Would this be some functionality that is interesting to add?

Not sure how it should / would work, maybe a new function or just integrating a test if it's a time into the current sorting func.

@Evertras
Copy link
Owner

Evertras commented Nov 2, 2024

The short answer is yes, that sounds useful to have available and shouldn't break any existing workflows that I could conceive of. Easiest thing to do would be to add a test to try it, and if it fails then we can add it in. It would be nice to have a test for that regardless, if you're willing to tinker.

I would generally expect this to already work, though. Sorting just tries to extract a string version of the inner value, which should be sortable as dates in Go are in a nice sortable ISO format: 2009-11-10 23:00:00 +0000 UTC m=+0.000000001

That being said, it's not perfect. If some times are in different timezones, for example, there may technically be some differences, but this feels like a weird edge case.

Also that being said, the current way is far from efficient. It has to turn each date into a full string, then compare the strings. It would be much faster if it was a direct comparison of time.Time values, so this may still be worth doing for performance reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants