7.3. Sorting and Tree View Column Headers

Unless you have hidden your tree view column headers or use custom tree view column header widgets, each tree view column's header can be made clickable. Clicking on a tree view column's header will then sort the list according to the data in that column. You need to do two things to make this happen: firstly, you need to tell your model which sort function to use for which sort column ID with gtk_tree_sortable_set_sort_func. Once you have done this, you tell each tree view column which sort column ID should be active if this column's header is clicked. This is done with gtk_tree_view_column_set_sort_column_id.

And that is really all you need to do to get your list or tree sorted. The tree view columns will automatically set the active sort column ID and sort order for you if you click on a column header.