次のタプルのリストがあります。
items = [
('john jones', ['Director', 'Screenwriter', 'Producer']),
('eric smith', ['Screenwriter']),
('anne smith', ['Producer']),
('emily smith', ['Director']),
('steven jones', ['Director', 'Screenwriter'])
]
「プロデューサー」の前に「脚本家」が表示される前に「監督」が表示されるように並べ替える必要があります。その中の実際の順序は重要ではありません。たとえば、これは有効な結果になります。
items = [
('john jones', ['Director', 'Screenwriter', 'Producer']),
('emily smith', ['Director']),
('steven jones', ['Director', 'Screenwriter'])
('anne smith', ['Producer']),
('eric smith', ['Screenwriter']),
]
この種の処理を行う方法はありますsorted(items, key=lambda x: ?)
か、それともリスト内の各項目を繰り返す必要がありますか?