Fix for #1750 - when sorting items in the item compare, items without that attribute cause an error due to None / int comparison

This commit is contained in:
blitzmann
2018-09-26 18:17:28 -04:00
parent 85746cd681
commit 0749e03211

View File

@@ -125,11 +125,11 @@ class ItemCompare(wx.Panel):
# Remember to reduce by 1, because the attrs array
# starts at 0 while the list has the item name as column 0.
attr = str(list(self.attrs.keys())[sort - 1])
func = lambda _val: _val.attributes[attr].value if attr in _val.attributes else None
func = lambda _val: _val.attributes[attr].value if attr in _val.attributes else 0.0
except IndexError:
# Clicked on a column that's not part of our array (price most likely)
self.sortReverse = False
func = lambda _val: _val.attributes['metaLevel'].value if 'metaLevel' in _val.attributes else None
func = lambda _val: _val.attributes['metaLevel'].value if 'metaLevel' in _val.attributes else 0.0
self.items = sorted(self.items, key=func, reverse=self.sortReverse)