wxTreeListCtrl Sorting a column with integers

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
DavidKlecker
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 232
Joined: Sun Nov 29, 2009 10:35 am

wxTreeListCtrl Sorting a column with integers

Post by DavidKlecker »

This is probably really easy but I'm not just not able to figure it out myself. I have a wxTreeListCtrl and one of the columns contains numbers. When I sort, I get back a sort result based on integers as a string, not as integers. Anyway to get SortChildren to sort on integers and not strings?

The code for it now is
void wxTreeListMainWindow::SortChildren (const wxTreeItemId& itemId, int column, bool reverseOrder) {
wxCHECK_RET (itemId.IsOk(), _T("invalid tree item"));

wxTreeListItem *item = (wxTreeListItem*) itemId.m_pItem;

wxCHECK_RET (!s_treeBeingSorted,
_T("wxTreeListMainWindow::SortChildren is not reentrant") );

wxArrayTreeListItems& children = item->GetChildren();
if ( children.Count() > 1 ) {
m_dirty = true;
s_treeBeingSorted = this;
m_sortColumn = column; // -1 indicates legacy mode
m_ReverseSortOrder = reverseOrder;
children.Sort(tree_ctrl_compare_func);
s_treeBeingSorted = NULL;
}
}
and wxArrayTreeListItems appears to be a WX_DEFINE_ARRAY_PTR

Thanks!
Post Reply