Reputation: 23
{1: {'p_place': {'x': 0.65, 'y': 0.255, 'z': 0.279}, 'q_place': {'q0': 1.0, 'q1': 0.0, 'q2': 0.0, 'q3': 0.0}, 'offset_pick': {'x': (0.0,), 'y': (0.0,), 'z': (0.05,)}, 'centroid_upper': {'x': (0.65,), 'y': (0.2549999999999998,), 'z': (0.329,)}}, 2: {'p_place': {'x': 0.65, 'y': 0.255, 'z': 0.279}, 'q_place': {'q0': 1.0, 'q1': 0.0, 'q2': 0.0, 'q3': 0.0}, 'offset_pick': {'x': (0.0,), 'y': (0.0,), 'z': (0.05,)}, 'centroid_upper': {'x': (0.65,), 'y': (0.2549999999999998,), 'z': (0.329,)}}}
I have this kind of dictionary. I want to sort it by value Y
and Z
of p_place
Upvotes: 1
Views: 42
Reputation: 54698
Did you try anything at all?
newd = sorted(dct, key=lambda el: (el['p_place']['y'],el['p_place']['z']))
Upvotes: 2