def select_best(population, cost_func, num_to_keep):
    """Select a given number of paths with the lowest cost (the best paths)

    Arguments received:
    population -- an array of lists of coordinates representing paths
    cost_func -- function to calculate cost of a path
    num_to_keep -- number of paths to select

    Arguments returned:
    [i[0] for i in scored_population[:num_to_keep]] -- an array of lists of coordinates representing the best paths
    """
    scored_population = [(i, cost_func(i)) for i in population]  # create a list of tuples: (path, cost)
    scored_population.sort(key=lambda x: x[1])  # sort list by cost, lowest to highest
    return [i[0] for i in scored_population[:num_to_keep]]