def select_trajectories(trajectories, trajectories_cost, trajectories_nb):
    """
    Return the trajectories associated with the smallest costs.

    Inputs:
        - trajectories: list of pd.DataFrame
            Each element of the list is a trajectory
        - trajectories_cost: ndarray
            Array containing the cost of the trajectories
        - trajectories_nb: int
            Number of trajectories to keep
    Ouput:
        - best_trajectories: list of pd.DataFrame
            List containing the best trajectories
    """
    # Sort indices with respect to costs
    indexes = sorted(range(len(trajectories)),
                     key=lambda k: trajectories_cost[k])
    # Keep the first ones
    best_trajectories = [trajectories[i] for i in indexes[:trajectories_nb]]

    return best_trajectories