From 5de689643355a7732d90a42b758e5708cedc9129 Mon Sep 17 00:00:00 2001
From: Dimitur Kirov <dkirov@gmail.com>
Date: Fri, 26 May 2006 20:41:03 +0000
Subject: [PATCH] sort resources by priority

---
 src/tooltips.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/tooltips.py b/src/tooltips.py
index f09cccbdd5..f8de2a26f0 100644
--- a/src/tooltips.py
+++ b/src/tooltips.py
@@ -525,17 +525,25 @@ class RosterTooltip(NotificationAreaTooltip):
 				properties.append((_('OpenPGP: '),
 					gtkgui_helpers.escape_for_pango_markup(keyID)))
 		num_resources = 0
+		# put contacts in dict, where key is priority
+		contacts_dict = {}
 		for contact in contacts:
 			if contact.resource:
 				num_resources += 1
+				if contact.priority in contacts_dict:
+					contacts_dict[contact.priority].append(contact)
+				else:
+					contacts_dict[contact.priority] = [contact]
 		
 		if num_resources== 1 and contact.resource:
 			properties.append((_('Resource: '),	gtkgui_helpers.escape_for_pango_markup(
 							contact.resource) + ' (' + unicode(contact.priority) + ')'))
 		if num_resources > 1:
 			properties.append((_('Status: '),	' '))
-			for contact in contacts:
-				if contact.resource:
+			contact_keys = contacts_dict.keys()
+			contact_keys.sort(reverse = True)
+			for priority in contact_keys:
+				for contact in contacts_dict[priority]:
 					status_line = self.get_status_info(contact.resource,
 						contact.priority, contact.show, contact.status)
 					
-- 
GitLab