From c890fefbc40377fd63f1d69011ed12a863e11043 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 1 Aug 2012 01:36:18 +0200 Subject: Add an "online" contact sorting method - put the online contacts at the beginning of the list - allows, e.g. jid_reverse_online_reverse, to put offline contacts at the start of the group, in alphabetical order --- src/roster.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/roster.py') diff --git a/src/roster.py b/src/roster.py index c7717ea8..c5f89218 100644 --- a/src/roster.py +++ b/src/roster.py @@ -255,11 +255,16 @@ def sort_resource_nb(contact): def sort_name(contact): return contact.name.lower() or contact.bare_jid +def sort_online(contact): + result = sort_show(contact) + return 0 if result < 5 else 1 + SORTING_METHODS = { 'jid': sort_jid, 'show': sort_show, 'resource': sort_resource_nb, 'name': sort_name, + 'online': sort_online, } class RosterGroup(object): -- cgit v1.2.3