An irritating behaviour of MultiColumnList are that they seem to sort=20
columns always like strings. And if you put integers in the =
MultiColumnList.items you get
errors so you have to change every thing to strings.(?)
So when you have a column with 'numbers' like 88,125,9,2
and click on the ColumnHeader it sorts thus 9,88,2,125
wich is mostly useless.
So now I changed some lines in the mixins from wx.
If anybody also wants a different sort behaviour do this.
In wx.lib.mixins.lstctrl change this lines in=20
__ColumnSorter(self,key1,key2):
col =3D self._col
ascending =3D self._colSortFlag[col]
item1 =3D self.itemDataMap[key1][col]
item2 =3D self.itemDataMap[key2][col]
#--- Internationalization of string sorting with locale module
if type(item1) =3D=3D type('') or type(item2) =3D=3D type(''):
cmpVal =3D locale.strcoll(str(item1), str(item2))
else:
cmpVal =3D cmp(item1, item2)
lines added underlined
col =3D self._col
ascending =3D self._colSortFlag[col]
item1 =3D self.itemDataMap[key1][col]
item2 =3D self.itemDataMap[key2][col]
#--- Internationalization of string sorting with locale module
if type(item1) =3D=3D type('') or type(item2) =3D=3D type(''):
if item1.isdigit() and item2.isdigit():
cmpVal=3Dcmp(float(item1),float(item2))
else:
cmpVal =3D locale.strcoll(str(item1), str(item2))
else:
cmpVal =3D cmp(item1, item2)
=20
So now the MultiColumnList recognizes numbers in the column, and sort =
according=20
to value...so 88,125,9,2 turns into 125,88,9,2
Any comments?
Tjerk Hoekstra
Castro Brazil |