make sure OrderedDict order is preserved in output

sorted(ret) will sort the keys on their own, discarding the original
order of the OrderedDict.
This commit is contained in:
Andreas Lutro 2017-02-14 13:39:55 +01:00
parent ec59ae67c8
commit 625a770a23

View file

@ -25,6 +25,7 @@ Example output::
'''
from __future__ import absolute_import
# Import python libs
import collections
from numbers import Number
# Import salt libs
@ -127,7 +128,14 @@ class NestDisplay(object):
'----------'
)
)
for key in sorted(ret):
# respect key ordering of ordered dicts
if isinstance(ret, collections.OrderedDict):
keys = ret.keys()
else:
keys = sorted(ret)
for key in keys:
val = ret[key]
out.append(
self.ustring(