diff --git a/blueman/gui/manager/ManagerDeviceMenu.py b/blueman/gui/manager/ManagerDeviceMenu.py
index 6bf3a566c..3bed94c81 100644
--- a/blueman/gui/manager/ManagerDeviceMenu.py
+++ b/blueman/gui/manager/ManagerDeviceMenu.py
@@ -1,6 +1,7 @@
import logging
from enum import Enum, auto
from gettext import gettext as _
+from operator import attrgetter
from typing import Dict, List, Tuple, Optional, TYPE_CHECKING, Union, Iterable
from blueman.Functions import create_menuitem, e_
@@ -306,12 +307,12 @@ def generate(self) -> None:
if connect_items:
self.append(self._create_header(_("Connect To:")))
- for it in sorted(connect_items, key=lambda i: i.position):
+ for it in sorted(connect_items, key=attrgetter("position")):
self.append(it.item)
if disconnect_items:
self.append(self._create_header(_("Disconnect:")))
- for it in sorted(disconnect_items, key=lambda i: i.position):
+ for it in sorted(disconnect_items, key=attrgetter("position")):
self.append(it.item)
config = AutoConnectConfig()
@@ -328,7 +329,7 @@ def generate(self) -> None:
item.show()
self.append(item)
- for it in sorted(autoconnect_items, key=lambda i: i.position):
+ for it in sorted(autoconnect_items, key=attrgetter("position")):
self.append(it.item)
if show_generic_connect or connect_items or disconnect_items or autoconnect_items:
@@ -336,7 +337,7 @@ def generate(self) -> None:
item.show()
self.append(item)
- for it in sorted(action_items, key=lambda i: i.position):
+ for it in sorted(action_items, key=attrgetter("position")):
self.append(it.item)
send_item = create_menuitem(_("Send a _Fileā¦"), "blueman-send-symbolic")
diff --git a/blueman/plugins/applet/StatusIcon.py b/blueman/plugins/applet/StatusIcon.py
index 6c8b60baf..6c2efd89c 100644
--- a/blueman/plugins/applet/StatusIcon.py
+++ b/blueman/plugins/applet/StatusIcon.py
@@ -1,4 +1,5 @@
from gettext import gettext as _
+from operator import itemgetter
from typing import Optional, Tuple, List
from gi.repository import GObject, GLib, Gio
@@ -117,7 +118,7 @@ def _get_status_icon_implementations(self) -> List[str]:
return [implementation for implementation, _ in sorted(
(plugin.on_query_status_icon_implementation()
for plugin in self.parent.Plugins.get_loaded_plugins(StatusIconImplementationProvider)),
- key=lambda implementation_priority: implementation_priority[1],
+ key=itemgetter(1),
reverse=True
)] + ["GtkStatusIcon"]