[GH-ISSUE #485] Sorting tables by column #354

Closed
opened 2026-03-04 01:04:15 +03:00 by kerem · 3 comments
Owner

Originally created by @IdlePhysicist on GitHub (Aug 15, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/485

Hi,

I would like to be able to sort tables by selecting a column. At present I do not see a way to do this in tview, but please correct me if there is!

If it is not possible please consider this a feature request.

Originally created by @IdlePhysicist on GitHub (Aug 15, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/485 Hi, I would like to be able to sort tables by selecting a column. At present I do not see a way to do this in tview, but please correct me if there is! If it is not possible please consider this a feature request.
kerem closed this issue 2026-03-04 01:04:16 +03:00
Author
Owner

@LazarenkoA commented on GitHub (Aug 18, 2020):

There is such a need too.
I use in a workaround, i.e. sorting the original array, clearing the tview and refilling it

<!-- gh-comment-id:675410721 --> @LazarenkoA commented on GitHub (Aug 18, 2020): There is such a need too. I use in a workaround, i.e. sorting the original array, clearing the tview and refilling it
Author
Owner

@rivo commented on GitHub (Sep 15, 2020):

At the moment, yes, you'd have to clear the table and refill it. I was thinking about adding an index map which would map the screen position of the table cell to the position in the original table data. Then you could sort the index map yourself. But I'm afraid this would pose a few problems. For example, how about fixed rows/columns (@tslocum, how did you solve that?). And when you access a cell, would you want to have the original position or the sorted position?

I'm more inclined to implement something like #248 where you have complete control over the data.

<!-- gh-comment-id:692683622 --> @rivo commented on GitHub (Sep 15, 2020): At the moment, yes, you'd have to clear the table and refill it. I was thinking about adding an index map which would map the screen position of the table cell to the position in the original table data. Then you could sort the index map yourself. But I'm afraid this would pose a few problems. For example, how about fixed rows/columns (@tslocum, how did you solve that?). And when you access a cell, would you want to have the original position or the sorted position? I'm more inclined to implement something like #248 where you have complete control over the data.
Author
Owner

@rivo commented on GitHub (Nov 9, 2021):

Virtual tables are now part of the package. This should allow you to implement sorting on your end. So I'm closing this issue for now.

<!-- gh-comment-id:964273526 --> @rivo commented on GitHub (Nov 9, 2021): Virtual tables are now part of the package. This should allow you to implement sorting on your end. So I'm closing this issue for now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#354
No description provided.