Skip to content

Commit 53a16b1

Browse files
Changed from lexographic file sorting to human sorting
1 parent 261098c commit 53a16b1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Converter/Sequence_Converter_UI.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import re
34
import configparser
45
from threading import Event
56
from threading import Lock
@@ -196,8 +197,8 @@ def validate_input_files(self, input_path):
196197
self.convertToSRGB = self.converter.get_image_gamme_encoded(os.path.join(input_path, self.imagePathList[0]))
197198
self.set_SRGB_enabled(self.convertToSRGB)
198199

199-
self.modelPathList.sort()
200-
self.imagePathList.sort()
200+
self.human_sort(self.modelPathList)
201+
self.human_sort(self.imagePathList)
201202

202203
return True
203204

@@ -259,6 +260,18 @@ def save_config(self):
259260
with open(self.configPath, "w") as configfile:
260261
self.config.write(configfile)
261262

263+
def tryint(self, s):
264+
try:
265+
return int(s)
266+
except ValueError:
267+
return s
268+
269+
def alphanum_key(self, s):
270+
return [ self.tryint(c) for c in re.split('([0-9]+)', s) ]
271+
272+
def human_sort(self, l):
273+
l.sort(key=self.alphanum_key)
274+
262275

263276
# --- Main UI ---
264277

0 commit comments

Comments
 (0)