Say I have images of dogs in a directory with its name and numbering as:
dog 1.jpg
dog 2.jpg
dog 3.jpg
.
.
dog 11.jpg
dog 12.jpg
when I perform sorted(glob.glob('that_dir/*jpg'))
and print
, it returns:
dog 1.jpg
dog 10.jpg
dog 11.jpg
dog 12.jpg
.
.
dog 8.jpg
dog 9.jpg
is there a way to make it return in order of dog 1.jpg, dog 2.jpg .. dog 12.jpg
in this case?
or is it wiser to avoid this numbering method altogether and use something like leading zeros instead?