mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-21 02:07:06 +02:00
sort_dict(): added
This commit is contained in:
1 parent
210e943157
commit
170a801652
1 file changed
+8
@@ -643,6 +643,14 @@ def get_JSON_value(json, key : str = None, keys : list = None, keypath = None):
|
||||
raise KeyError('Key not found: ' + get_JSON_keypath(keypath, keys[0]))
|
||||
|
||||
|
||||
def sort_dict(d: dict, number: bool = False) -> dict:
|
||||
"""Sort a dict by keys"""
|
||||
if number:
|
||||
return dict(sorted(d.items(), key=lambda item: int(item[0])))
|
||||
else:
|
||||
return dict(sorted(d.items(), key=lambda item: item[0]))
|
||||
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Class SlowBar
|
||||
# -----------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user