From d5cd58a738ad8e8ad0a5010f9cff904736e1719a Mon Sep 17 00:00:00 2001 From: Nick Schwane Date: Wed, 18 Oct 2023 13:27:19 -0400 Subject: [PATCH] feat: fix integer priority sorting (#327) * fix: fix integer priority sorting * fix: fix formatting with black --- casbin/model/model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/casbin/model/model.py b/casbin/model/model.py index e33fd71..ecef775 100644 --- a/casbin/model/model.py +++ b/casbin/model/model.py @@ -124,7 +124,12 @@ def sort_policies_by_priority(self): if assertion.priority_index == -1: continue - assertion.policy = sorted(assertion.policy, key=lambda x: x[assertion.priority_index]) + assertion.policy = sorted( + assertion.policy, + key=lambda x: int(x[assertion.priority_index]) + if x[assertion.priority_index].isdigit() + else x[assertion.priority_index], + ) for i, policy in enumerate(assertion.policy): assertion.policy_map[",".join(policy)] = i