diff --git a/ffmpeg/_utils.py b/ffmpeg/_utils.py index 9b575a0..d3acc4c 100644 --- a/ffmpeg/_utils.py +++ b/ffmpeg/_utils.py @@ -27,6 +27,7 @@ def get_hash(item): repr_ = _recursive_repr(item).encode('utf-8') return hashlib.md5(repr_).hexdigest() + def get_hash_int(item): return int(get_hash(item), base=16) @@ -41,3 +42,8 @@ def escape_chars(text, chars): for ch in chars: text = text.replace(ch, '\\' + ch) return text + + +def sort_ordereddict(d): + for key in sorted(d.keys()): + d.move_to_end(key) diff --git a/ffmpeg/dag.py b/ffmpeg/dag.py index 86c695f..7e6b91e 100644 --- a/ffmpeg/dag.py +++ b/ffmpeg/dag.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from ._utils import get_hash, get_hash_int +from ._utils import get_hash, get_hash_int, sort_ordereddict from builtins import object from collections import namedtuple, OrderedDict @@ -177,7 +177,6 @@ def topo_sort(downstream_nodes): # Sort outgoing edge maps by upstream label for map in outgoing_edge_maps.values(): - for label in sorted(map.keys()): - map.move_to_end(label) + sort_ordereddict(map) return sorted_nodes, outgoing_edge_maps