Skip to content

Commit

Permalink
fix(util): copy list before sorting
Browse files Browse the repository at this point in the history
Closes #221
  • Loading branch information
nritsche committed Nov 19, 2020
1 parent 89db51a commit c92d32b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions coco/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ def sort_list(list_: Dict):
lists it contains at any depths are sorted. Note that the list and any
contained lists are not sorted themselves.
"""
for i, item in enumerate(list_):
list_copy = copy.copy(list_)
for i, item in enumerate(list_copy):
if isinstance(item, dict):
list_[i] = sort_dict(item)
list_copy[i] = sort_dict(item)
elif isinstance(item, list):
list_[i] = sort_list(item)
return list_
list_copy[i] = sort_list(item)
return list_copy

0 comments on commit c92d32b

Please sign in to comment.