Find shard boundary
Your task
A key value store spreads its keyspace over shards and routes every request through a boundary table. boundaries is sorted ascending and holds no repeats, and boundaries[i] is the first key belonging to shard i + 1. Shard 0 therefore holds every key ordered before boundaries[0], a middle shard holds the keys from its own boundary up to but not including the next one, and the last shard holds every key at or after the final boundary. A key equal to a boundary belongs to the shard that boundary opens, the higher of the two. Keys compare as ordinary text, character by character, so capitals come before lowercase. Return the shard index for each entry of keys, in the order given. A table with no boundaries means a single shard, so every key routes to 0, and an empty key list returns an empty list. The table is consulted on every request, so halve it rather than scan it.
Examples
route_keys_to_shards(boundaries: list[str], keys: list[str]) -> list[int]route_keys_to_shards(["dana", "mira", "tomas"], ["alice", "dana", "evan", "mira", "zoe", "tomas"])[0, 1, 1, 2, 3, 3]route_keys_to_shards(["dana", "mira", "tomas"], ["Zed", "mir", "mirabel", "tomas"])[0, 1, 2, 3]