From bf169f302abafce170d0668bf34e53c98e639294 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Wed, 5 Nov 2008 18:31:06 +0000
Subject: [PATCH] [thorstenp] sort emoticons with sorted function. See #4457

---
 src/gajim.py | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/src/gajim.py b/src/gajim.py
index 85322ad3b7..2ac91a2eef 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -2460,8 +2460,7 @@ class Interface:
 			# expanded.  e.g., foo:) NO, foo :) YES, (brb) NO, (:)) YES, etc.
 			# We still allow multiple emoticons side-by-side like :P:P:P
 			# sort keys by length so :qwe emot is checked before :q
-			keys = self.emoticons.keys()
-			keys.sort(self.on_emoticon_sort)
+			keys = sorted(self.emoticons, key=len, reverse=True)
 			emoticons_pattern_prematch = ''
 			emoticons_pattern_postmatch = ''
 			emoticon_length = 0
@@ -2494,15 +2493,6 @@ class Interface:
 		# Invalid XML chars
 		self.invalid_XML_chars = u'[\x00-\x08]|[\x0b-\x0c]|[\x0e-\x19]|[\ud800-\udfff]|[\ufffe-\uffff]'
 
-	def on_emoticon_sort(self, emot1, emot2):
-		len1 = len(emot1)
-		len2 = len(emot2)
-		if len1 < len2:
-			return 1
-		elif len1 > len2:
-			return -1
-		return 0
-
 	def popup_emoticons_under_button(self, button, parent_win):
 		''' pops emoticons menu under button, located in parent_win'''
 		gtkgui_helpers.popup_emoticons_under_button(self.emoticons_menu,
-- 
GitLab