From fd41b55fa5217c48b6d295100387f53bccb71696 Mon Sep 17 00:00:00 2001
From: legac <renaud.legac@free.fr>
Date: Wed, 22 Feb 2012 21:56:32 +0100
Subject: [PATCH] Add a method to sort children according to alphabetical
 order.

---
 modules/plugin_dbui/navtree.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py
index 550e1a4d..ed6bfae6 100644
--- a/modules/plugin_dbui/navtree.py
+++ b/modules/plugin_dbui/navtree.py
@@ -159,3 +159,19 @@ class Node(object):
         
         """
         return {'text': self.text, 'children': self.children}
+
+
+    def sort_children(self):
+        """sort children according to alphabetical order.
+        
+        """
+        di = {}
+        for child in self.children:
+            di[child['text']] = child
+            
+        names = di.keys()
+        names.sort(cmp=locale.strcoll)
+        
+        self.children = []
+        for name in names:
+            self.children.append(di[name])
-- 
GitLab