/ Published in: Python
Sorting strings in an array like : "toto-2.csv", "toto-4.csv", "toto-12.csv" and "toto-101.csv".
Expand |
Embed | Plain Text
#Sorting strings in an array like filePaths = ["toto-2.csv", "toto-4.csv", "toto-12.csv" and "toto-101.csv"] keyfunction = lambda filePath : int(re.findall('(\d*)\.csv', filePath)[0]) filePaths.sort(key=keyfunction)
You need to login to post a comment.
