fix: simplify sort condition

This commit is contained in:
Rushabh Mehta 2019-05-02 09:22:48 +05:30
parent 7ca243094e
commit 27a30c842d

View File

@ -331,11 +331,7 @@ def sort_accounts(accounts, is_root=False, key="name"):
if a.root_type == "Income" and b.root_type == "Expense": if a.root_type == "Income" and b.root_type == "Expense":
return -1 return -1
else: else:
if re.split('\W+', a[key])[0].isdigit(): # sort by key (number) or name
# if chart of accounts is numbered, then sort by number
return cmp(a[key], b[key])
else:
# common, this should be alphabetic otherwise!
return cmp(a[key], b[key]) return cmp(a[key], b[key])
return 1 return 1