+ // sort the attributes too
+ if ( m_hasAnyAttr )
+ {
+ int n,
+ count = GetItemCount();
+ int *aItems = new int[count];
+ for ( n = 0; n < count; n++ )
+ {
+ aItems[n] = n;
+ }
+
+ gs_sortData = data;
+ gs_sortCtrl = this;
+ gs_sortFunction = fn;
+
+ qsort(aItems, count, sizeof(int), wxListCtrlCompareFn);
+
+ gs_sortData = 0;
+ gs_sortCtrl = NULL;
+ gs_sortFunction = NULL;
+
+ wxHashTable attrsNew(wxKEY_INTEGER, 1000);
+ for ( n = 0; n < count; n++ )
+ {
+ wxObject *attr = m_attrs.Delete(aItems[n]);
+ if ( attr )
+ {
+ attrsNew.Put(n, attr);
+ }
+ }
+
+ m_attrs.Destroy();
+ m_attrs = attrsNew;
+
+ delete [] aItems;
+ }
+
+ if ( !ListView_SortItems(GetHwnd(), (PFNLVCOMPARE)fn, data) )
+ {
+ wxLogDebug(_T("ListView_SortItems() failed"));
+
+ return FALSE;
+ }
+
+ return TRUE;