Simplify sorting code

For https://github.com/pypa/pipenv/issues/5964
As suggested in https://github.com/pypa/pipenv/pull/5965

We don't need to cast to `dict` first, we can just sort.
This commit is contained in:
Dave Schaefer
2023-10-20 17:35:16 -06:00
parent 4802425c86
commit 1a8c9de922
+1 -2
View File
@@ -1114,9 +1114,8 @@ class Project:
def _sort_category(self, category):
# toml tables won't maintain sorted dictionary order
# so construct the table in the order that we need
sorted_category = dict(sorted(category.items()))
table = tomlkit.table()
for key, value in sorted_category.items():
for key, value in sorted(category.items()):
table.add(key, value)
return table