ebookmaker icon indicating copy to clipboard operation
ebookmaker copied to clipboard

Wild cards are sorted as strings

Open progtologist opened this issue 9 years ago • 0 comments

This issue affects users with more than 9 text files.

# Expand wild cards.
if item['type'] == 'text' and '*' in item['source']:
    files = sorted(glob(item['source']))

The simple sorted function sort the filenames with the wildcard as strings, which in the case where the filenames are 'file1, file2,... , file10' the sorted list ends up as 'file1, file10, file2, ..., file9'. To fix this I used the natsort package, but I leave it up to the author to choose his prefered method to naturally sort filenames.

from natsort import natsorted

# Expand wild cards.
if item['type'] == 'text' and '*' in item['source']:
    files = natsorted(glob(item['source']))

progtologist avatar Aug 19 '15 11:08 progtologist