Best Way to Sort a ListControl List in an Xml Dialog
#1
I'm using a WindowXmlDialog with a list control. The List items that I put in the list have a 'date' property. What's the best way to sort my list by date in ascending order?

I've seen how users of xbmc.plugin can specify sort methods but I don't see how one would sort a list in an XML dialog.
Reply
#2
it's not possble to use sort methods in scripts.
if a list needs to be sorted, you'll have to do the sorting in your python code.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
I thought that was the case and created my own sort function in my addon code for V17.6.
Unfortunately under V18.1, the following code crashes Kodi:
Python:

itemlist = self.getItemList()
newlist = sorted(itemlist, key=lambda item: item.getProperty('alarmtime'))
self.list.reset()
self.list.addItems(newlist)

I've used Web-Pdb to debug the above sort code and all is well until I get to the last line. At that point Kodi crashes and reboots.
Reply
#4
I submitted a bug report for this crashing problem: https://github.com/xbmc/xbmc/issues/15750
Reply

Logout Mark Read Team Forum Stats Members Help
Best Way to Sort a ListControl List in an Xml Dialog0