SortItems example?

Hi friends,

Could you show me example of how to use the SortItems method of ListCtrl class? For example I want sort ListCtrl items by first column by ascending value, i.e the list:
1 ...
3 ...
2 ...
4 ...

should turn into:
1 ...
2 ...
3 ...
4 ...

Please, give me a code snippets for example.

Thanks in advance!

Hi friends,

Could you show me example of how to use the SortItems method of ListCtrl
class? For example I want sort ListCtrl items by first column by
ascending value, i.e the list:

[snip]

Please, give me a code snippets for example.

See the ListCtrl demo in the wxPython demo. It is available for
download near the bottom of this page:
http://www.wxpython.org/download.php

- Josiah

···

Basil Shubin <bashu@yandex.ru> wrote:

Basil Shubin wrote:

Hi friends,

Could you show me example of how to use the SortItems method of ListCtrl class? For example I want sort ListCtrl items by first column by ascending value, i.e the list:
1 ...
3 ...
2 ...
4 ...

should turn into:
1 ...
2 ...
3 ...
4 ...

Please, give me a code snippets for example.

There is a wx.lib.mixins.listctrl.ColSorterMixin class that you can use as shown in the demo to sort when a col header is clicked on. If you would rather handle sorting yourself then you can do that with the SortItems method. You just need to pass it the function to use to compare items. That function should accept 2 parameters which are the client data values of the items to be sorted, so you should have a way to get from the data value to the values to be compared.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!