NumPy allowed · plain Python earns 10 bonus points
Cosine-like similarity scores ranked before context assembly
Implement the scatter-gather merge step every distributed vector search does: each shard returns its own top-k, and the query router must merge them into one global top-k.
Implement merge_shard_topk(shard_results, k). Each element of shard_results is a list of (id, score) tuples, already sorted descending by score within its shard (higher score = more relevant). Merge all shards' results and return the global top-k (id, score) tuples sorted descending by score; ties broken by id ascending.
merge_shard_topk(shard_results: list[list[tuple]], k: int) -> list[tuple]