The sort package on the standard library includes an interface that if you implement it for any type then it can be sorted using the sort.Sort()
function.
Even if the ui.Table
object is from a package or library you can't modify, you can always declare a new type using ui.Table
as it's base and implement the sort.Interface
yourself, something like:
type myTable ui.Table
func (m myTable) Len() int { return len(m) }
func (m myTable) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
func (m myTable) Less(i, j int) bool { return m[i].col() < m[j].col() }
Or you know some implementation that makes sense for the Table type. Here I'm assuming that your rows have a function col()
that returns the value of the column you are using to sort for that row and that Table
is a slice of rows which is probably not the case.
I wish I could help more but it's not possible to help you with any implementation details if you don't give any details about ui.Table
.