in selftest/selftest.py [0:0]
def device_sort(devices: List[str]) -> List[str]:
"""Natural sort for devices."""
def natural_sort_key(s: str):
# Natural sort by turning a string into a list of string and number chunks.
# e.g. "nvme0n10" -> ["nvme", 0, "n", 10]
return [
int(text) if text.isdigit() else text for text in re.split("([0-9]+)", s)
]
return sorted(devices, key=natural_sort_key)