Quantcast
Channel: Sort a list of names containing numbers by the numeric value - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Mihai Alexandru-Ionut for Sort a list of names containing numbers...

Since all the strings of your given list are ended in .avi extension, you could use a slicing feature. sorted(lst, key=lambda x: int(x[:-4]))

View Article


Answer by Eugene Yarmash for Sort a list of names containing numbers by the...

You can use a custom sorting function to extract the number from each element of the list and use it as the comparison key. You'd need to convert it to int to ensure it compares like number:...

View Article


Sort a list of names containing numbers by the numeric value

I would like to sort a list which includes a set such as; 100.avi 10000.avi 10002.avi 1003.avi .... I need to do some process using the files in numeric order. If I use sorted it does not care about...

View Article
Browsing latest articles
Browse All 3 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>