File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,17 @@ def util_qt_strlistclass():
59
59
return QStringList if have_qstring () else list
60
60
61
61
62
+ def natural_sort (list , key = lambda s :s ):
63
+ """
64
+ Sort the list into natural alphanumeric order.
65
+ """
66
+ def get_alphanum_key_func (key ):
67
+ convert = lambda text : int (text ) if text .isdigit () else text
68
+ return lambda s : [convert (c ) for c in re .split ('([0-9]+)' , key (s ))]
69
+ sort_key = get_alphanum_key_func (key )
70
+ list .sort (key = sort_key )
71
+
72
+
62
73
class WindowMixin (object ):
63
74
64
75
def menu (self , title , actions = None ):
@@ -1140,7 +1151,7 @@ def scanAllImages(self, folderPath):
1140
1151
relativePath = os .path .join (root , file )
1141
1152
path = ustr (os .path .abspath (relativePath ))
1142
1153
images .append (path )
1143
- images . sort ( key = lambda x : x .lower ())
1154
+ natural_sort ( images , key = lambda x : x .lower ())
1144
1155
return images
1145
1156
1146
1157
def changeSavedirDialog (self , _value = False ):
You can’t perform that action at this time.
0 commit comments