def order_slaves_on_gtid(slaves):

    """Function:  order_slaves_on_gtid

    Description:  Take a Slave array and sort them on their GTID positions,
        with the top(first) slave being the best Slave.

    Arguments:
        (input) slaves -> Slave instance array.
        (output) slave_list -> List of slaves in best order.

    """

    slaves = list(slaves)
    slave_list = []

    for slv in slaves:
        slave_list.append((slv.exe_gtidset, slv))

    slave_list.sort(key=lambda item: item[0])

    return slave_list