Tell me about a time you solved a coding problem related to the data lifecycle end to end.
For the coding portion, implement summarize_lifecycle(events). Each event is a dictionary with entity_id, stage, and integer timestamp. Return one dictionary per entity, ordered by entity_id, containing the unique stages in chronological order and the entity's final stage. Events may be unordered, and repeated stages should appear only once.
events is a list of event dictionaries. Return a list of dictionaries with keys entity_id, stages, and final_stage.
def summarize_lifecycle(events):