def bypcs(k):
    return promotion_items[k]['remaining_pcs']
byrempcs = sorted(promotion_items, key=bypcs)

def bydra(k):
    return promotion_items[k]['discount_ratio']
Sort by key of dictionary inside a dictionary in Python