From 27a30c842d0b39a96e6b5e43527dc6bb8c8f1584 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2019 09:22:48 +0530 Subject: [PATCH] fix: simplify sort condition --- erpnext/accounts/report/financial_statements.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index eea77ed6101..214031582f0 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -331,12 +331,8 @@ def sort_accounts(accounts, is_root=False, key="name"): if a.root_type == "Income" and b.root_type == "Expense": return -1 else: - if re.split('\W+', a[key])[0].isdigit(): - # 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]) + # sort by key (number) or name + return cmp(a[key], b[key]) return 1 accounts.sort(key = functools.cmp_to_key(compare_accounts))