in gpudirect-tcpxo/topology-scheduler/schedule-daemon.py [0:0]
def pod_sorting_key(pod):
"""Returns key to be used for sorting pods.
Given that numbers is often suffixed for multi-node deployments,
here we use a (prefix, number) tuple for the sorting key.
This means "xxx-pod2" should appear before "xxx-pod10"
"""
if pod['index'] is not None:
return int(pod['index'])
# if the suffix is a number, extract it
idx = 0
suffix = ""
name = pod['name']
while name[-1 - len(suffix)].isdigit():
suffix = name[-1 - len(suffix)] + suffix
if suffix != "":
idx = int(suffix)
return (name[:len(name) - len(suffix)], idx)