john_helt
john_helt2mo ago

Sorting tables elements that are not fully strings, floats or ints

Hi. I'm looking to sort tables that contain values which are numeric, but to help the user, I want to add a colorbar in the cell. Because I do that the elements can no longer be sorted. Is there a workaround to allow the cells to be sorted still? I would rather that, than placing colorbar in a separate column. This goes for any type of composite type of cell really. It would be great if you could still sort (given some condition that is sortable).
No description
Solution:
Not currently. I would suggest another column. You could try: 1. Custom format_mapping. Keep the value the same, but add the color in the format function: ```python...
Jump to solution
1 Reply
Solution
Myles Scolnick
Myles Scolnick2mo ago
Not currently. I would suggest another column. You could try: 1. Custom format_mapping. Keep the value the same, but add the color in the format function:
table = mo.ui.table(
data=[
{"first_name": "Michael", "last_name": "Scott", "age": 45},
],
format_mapping={
"first_name": format_name, # Use callable to format
},
)
table = mo.ui.table(
data=[
{"first_name": "Michael", "last_name": "Scott", "age": 45},
],
format_mapping={
"first_name": format_name, # Use callable to format
},
)
2. Custom ordering on the object itself. see https://www.geeksforgeeks.org/sorting-objects-of-user-defined-class-in-python/