<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def gbest_idx(swarm):
 """ gbest Neighbourhood topology function. Args: swarm: list: The list of particles. Returns: int: The index of the gbest particle. """

    best = 0
    cmp = comparator(swarm[best].best_fitness)
    for (idx, particle) in enumerate(swarm):
        if cmp(particle.best_fitness, swarm[best].best_fitness):
            best = idx
    return best