From cbc7d36669cf14d2319c28fa03ea4ec9539cf04c Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sun, 14 Mar 2010 17:05:40 +0100 Subject: [PATCH] take "position" parameter into account when sorting channels --- pyweb/mumble/mmobjects.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyweb/mumble/mmobjects.py b/pyweb/mumble/mmobjects.py index 6bc2919..711b756 100644 --- a/pyweb/mumble/mmobjects.py +++ b/pyweb/mumble/mmobjects.py @@ -23,6 +23,13 @@ from django.utils.http import urlquote from django.conf import settings +def cmp_channels( left, rite ): + byorder = cmp( left.position, rite.position ); + if byorder != 0: + return byorder; + else: + return cmp_names( left, rite ); + def cmp_names( left, rite ): """ Compare two objects by their name property. """ return cmp( left.name, rite.name ); @@ -97,7 +104,7 @@ class mmChannel( object ): def sort( self ): """ Sort my subchannels and players, and then iterate over them and sort them recursively. """ - self.subchans.sort( cmp_names ); + self.subchans.sort( cmp_channels ); self.players.sort( cmp_names ); for subc in self.subchans: subc.sort();