Index: filters/subscription_sort.py |
diff --git a/filters/subscription_sort.py b/filters/subscription_sort.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..62084603ceb928db2f4317a7abbba01992939a10 |
--- /dev/null |
+++ b/filters/subscription_sort.py |
@@ -0,0 +1,17 @@ |
+def subscription_sort(value, prioritizeRecommended=True): |
Sebastian Noack
2015/02/13 17:51:49
Nit: Please use underscores instead camelcase in P
kzar
2015/02/20 14:55:18
Done.
|
+ value = value[:] # create a copy of the list |
+ if prioritizeRecommended: |
+ value.sort(lambda a, b: ( |
+ cmp(a.get("type"), b.get("type")) or |
+ cmp(a.get("deprecated"), b.get("deprecated")) or |
+ cmp(b.get("catchall"), a.get("catchall")) or |
+ cmp(b.get("recommendation") != None, a.get("recommendation") != None) or |
Sebastian Noack
2015/02/13 17:51:49
None is a singleton. So please always use the "is
kzar
2015/02/20 14:55:18
Done.
|
+ cmp(a.get("name").lower(), b.get("name").lower()) |
Sebastian Noack
2015/02/13 17:51:49
This code will raise an exception anyway if "name"
kzar
2015/02/20 14:55:18
Done.
|
+ )) |
+ else: |
+ value.sort(lambda a, b: ( |
+ cmp(a.get("type"), b.get("type")) or |
+ cmp(a.get("deprecated"), b.get("deprecated")) or |
+ cmp(a.get("name").lower(), b.get("name").lower()) |
+ )) |
+ return value |