Added Nice Sorting Functionality using RE
Yeah
This commit is contained in:
parent
06afb118d7
commit
d30a1dcb62
1 changed files with 13 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
# THIS FILE IS A PART OF VCStudio
|
||||
# PYTHON 3
|
||||
|
||||
import re
|
||||
|
||||
# This is collection of simple geometric math operations that I gonna use trough
|
||||
# out the UI of the VCStudio. Stuff like collision detections, overlap detections
|
||||
|
@ -161,3 +162,15 @@ def timestring(tleft):
|
|||
|
||||
|
||||
|
||||
def tryint(s):
|
||||
try:
|
||||
return int(s)
|
||||
except:
|
||||
return s
|
||||
|
||||
def alphanum_key(s):
|
||||
return [ tryint(c) for c in re.split('([0-9]+)', s) ]
|
||||
|
||||
def sort_nicely(l):
|
||||
l.sort(key=alphanum_key)
|
||||
|
||||
|
|
Loading…
Reference in a new issue