If 'remaining_pcs' and 'discount_ratio' are the only keys in nested dictionaries, then:
result = sorted(promotion_items.iteritems(), key=lambda pair: pair[1].items())
If there were other keys, then:
def item_value(pair): return pair[1]['remaining_pcs'], pair[1]['discount_ratio'] result = sorted(promotion_items.iteritems(), key=item_value)
source share