in azure-slurm/slurmcc/util.py [0:0]
def to_hostlist(nodes: Union[str, List[str]], scontrol_func: Callable=scontrol) -> str:
"""
convert name-[1-5] into name-1 name-2 name-3 name-4 name-5
"""
assert nodes
for n in nodes:
assert n
if isinstance(nodes, list):
nodes_str = ",".join(nodes)
else:
nodes_str = nodes
# prevent poor sorting of nodes and getting node lists like htc-1,htc-10-19, htc-2, htc-20-29 etc
sorted_nodes = sorted(nodes_str.split(","), key=get_sort_key_func(is_hpc=False))
nodes_str = ",".join(sorted_nodes)
return scontrol_func(["show", "hostlist", nodes_str])