Skip to content

Commit d5cd58a

Browse files
authored
feat: fix integer priority sorting (#327)
* fix: fix integer priority sorting * fix: fix formatting with black
1 parent 49880cb commit d5cd58a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

casbin/model/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def sort_policies_by_priority(self):
124124
if assertion.priority_index == -1:
125125
continue
126126

127-
assertion.policy = sorted(assertion.policy, key=lambda x: x[assertion.priority_index])
127+
assertion.policy = sorted(
128+
assertion.policy,
129+
key=lambda x: int(x[assertion.priority_index])
130+
if x[assertion.priority_index].isdigit()
131+
else x[assertion.priority_index],
132+
)
128133

129134
for i, policy in enumerate(assertion.policy):
130135
assertion.policy_map[",".join(policy)] = i

0 commit comments

Comments
 (0)