Given an array of delivery coordinates, write an algorithm to find the closest driver-restaurant pairs within a specific threshold. Use Euclidean distance and include every driver-restaurant pair whose distance is less than or equal to the threshold. The function accepts drivers, restaurants, and threshold, and returns pairs as [driver_index, restaurant_index], ordered by ascending distance, then driver index, then restaurant index.
def find_closest_pairs(drivers, restaurants, threshold):