From e2db680b9ebd789a695fb0cd96f95bdcfa559069 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 7 Feb 2022 08:02:32 +0530 Subject: [PATCH] Catch NoneType in helpers.py/multikeysort --- headphones/helpers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/headphones/helpers.py b/headphones/helpers.py index a1f216ec..af9bb9a2 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -52,7 +52,14 @@ def cmp(x, y): https://portingguide.readthedocs.io/en/latest/comparisons.html#the-cmp-function """ - return (x > y) - (x < y) + if x is None and y is None: + return 0 + elif x is None: + return -1 + elif y is None: + return 1 + else: + return (x > y) - (x < y) def multikeysort(items, columns): comparers = [