Skip to content

Commit

Permalink
feat: fix integer priority sorting (#327)
Browse files Browse the repository at this point in the history
* fix: fix integer priority sorting

* fix: fix formatting with black
  • Loading branch information
nschwane committed Oct 18, 2023
1 parent 49880cb commit d5cd58a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion casbin/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5cd58a

Please sign in to comment.