I have the following list of tuples:
items = [
('john jones', ['Director', 'Screenwriter', 'Producer']),
('eric smith', ['Screenwriter']),
('anne smith', ['Producer']),
('emily smith', ['Director']),
('steven jones', ['Director', 'Screenwriter'])
]
I need to sort it such that "Director" appears before "Screenwriter" appears before "Producer". The actual ordering therein doesn't matter. For example, this would be a valid outcome:
items = [
('john jones', ['Director', 'Screenwriter', 'Producer']),
('emily smith', ['Director']),
('steven jones', ['Director', 'Screenwriter'])
('anne smith', ['Producer']),
('eric smith', ['Screenwriter']),
]
Is there a way to do this sort doing sorted(items, key=lambda x: ?), or do I have to iterate each item in the list?
collections.OrderedDictmight be an appropriate structure here.