def item_value(pair):
    return pair[1]['remaining_pcs'], pair[1]['discount_ratio']
result = sorted(iter(promotion_items.items()), key=item_value)
Sort by key of dictionary inside a dictionary in Python