Don't worry, I decided to take a quick look and went on a lambda rampage
e.g.:
Code:
# sort the list by option
if self.options.sortby == "DEFAULT":
pidginAccountDataList.sort(key=lambda obj: (str(obj.status)+obj.protocol.lower()+obj.name.lower()))
pidginDataList.sort(key=lambda obj: (str(obj.status)+obj.group.lower()+alias.lower()))
elif self.options.sortby == "NAME":
pidginAccountDataList.sort(key=lambda obj: (obj.name.lower()+str(obj.status)+obj.protocol.lower()))
pidginDataList.sort(key=lambda obj: (obj.name+obj.alias+obj.group+str(obj.status)))
elif self.options.sortby == "ALIAS":
pidginAccountDataList.sort(key=lambda obj: (obj.name.lower()+str(obj.status)+obj.protocol.lower()))
pidginDataList.sort(key=lambda obj: (obj.alias+obj.name+obj.group+str(obj.status)))
elif self.options.sortby == "GROUP":
pidginAccountDataList.sort(key=lambda obj: (obj.name.lower()+str(obj.status)+obj.protocol.lower()))
pidginDataList.sort(key=lambda obj: (obj.group+obj.name+obj.alias+str(obj.status)))
elif self.options.sortby == "STATUS":
pidginAccountDataList.sort(key=lambda obj: (obj.name.lower()+str(obj.status)+obj.protocol.lower()))
pidginDataList.sort(key=lambda obj: str(obj.status)+obj.name+obj.alias+obj.group)
elif self.options.sortby == "LOGACTIVITY":
pidginAccountDataList.sort(key=lambda obj: (str(obj.status)+obj.protocol.lower()+obj.name.lower()))
pidginDataList.sort(key=lambda obj: obj.activitydatetime,reverse=True)
else:
raise Exception("Invalid sortby option provided")
I won't have time to release the package today (launchpad is being reallllllly slowly i.e. 20 hours for a build) but find attached a marginally tested new version of the .py file....let me know if that works for you!
Here's the help listing for the --sortby method:
Code:
-s METHOD, --sortby=METHOD
[default: DEFAULT] Sort options for both buddy and
account listings. These are DEFAULT, NAME, ALIAS,
GROUP, STATUS or LOGACTIVITY. ALIAS, GROUP and
LOGACTIVITY sort options are not applicable for
account listings so appropriate sorting methods are
used instead. LOGACTIVITY is useful when limiting the
list size with the limit option.
Have fun
Bookmarks