Merge event streams

Write codeMedium30 minDatabricks style

Your task

You are given several event streams, each a list of [timestamp, payload] pairs already sorted by ascending timestamp. Merge them into a single chronologically ordered list of payloads. When multiple events share the same timestamp, order them by the index of the stream they came from (lower stream index first). Return the list of payloads in merged order.

Examples

merge_event_streams(streams: list[list[list]]) -> list
Example 1
Inputmerge_event_streams([[[1, "a"], [4, "d"]], [[1, "b"], [3, "c"]]])
Output["a", "b", "c", "d"]