Closed thet closed 2 years ago
they are probably not respecting i18n.
What is the preferred sort key? title
or id
? If we use title
, should it be case sensitive?
Sorting based on id
(my favorite, because then its language/i18n independent):
def get_addons_in_order(self, addons):
return sorted(addons, key=lambda x: x['id'])
Sorting based on title
:
def get_addons_in_order(self, addons):
return sorted(addons, key=lambda x: x['title'])
Sorting based on title
, case insensitive:
def get_addons_in_order(self, addons):
return sorted(addons, key=lambda x: x['title'].lower())
To use it, the method should be called by the view methods:
def get_upgrades(self):
"""
Return a list of products that have upgrades on tap
"""
return self.get_addons_in_order(
self.get_addons(apply_filter='upgrades').values()
)
def get_installed(self):
return self.get_addons_in_order(
self.get_addons(apply_filter='installed').values()
)
def get_available(self):
return self.get_addons_in_order(
self.get_addons(apply_filter='available').values()
)
def get_broken(self):
return self.get_addons_in_order(
self.get_addons(apply_filter='broken').values()
)
I cannot identify a pattern how the plugins in
prefs_install_products_form
are sorted. Should be sorted by title, probably.