Ensure 0%-100% spoolup is sorted properly
This commit is contained in:
@@ -7,6 +7,7 @@ import wx
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenuUnconditional
|
||||
from gui.utils.sorter import smartSort
|
||||
from service.damagePattern import DamagePattern as DmgPatternSvc
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -32,7 +33,7 @@ class ChangeDamagePattern(ContextMenuUnconditional):
|
||||
# Order here is important: patterns with duplicate names from the latter will overwrite
|
||||
# patterns from the former
|
||||
self.patterns = list(chain(sDP.getBuiltinDamagePatternList(), sDP.getUserDamagePatternList()))
|
||||
self.patterns.sort(key=lambda p: (p.fullName not in ["Uniform", "Selected Ammo"], p.fullName))
|
||||
self.patterns.sort(key=lambda p: (p.fullName not in ["Uniform", "Selected Ammo"], smartSort(p.fullName)))
|
||||
|
||||
self.patternEventMap = {}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import wx
|
||||
import gui.mainFrame
|
||||
from eos.saveddata.targetProfile import TargetProfile
|
||||
from gui.contextMenu import ContextMenuUnconditional
|
||||
from gui.utils.sorter import smartSort
|
||||
from service.targetProfile import TargetProfile as svc_TargetProfile
|
||||
|
||||
|
||||
@@ -48,7 +49,7 @@ class TargetProfileAdder(ContextMenuUnconditional):
|
||||
self.callingWindow = callingWindow
|
||||
sTR = svc_TargetProfile.getInstance()
|
||||
profiles = list(chain(sTR.getBuiltinTargetProfileList(), sTR.getUserTargetProfileList()))
|
||||
profiles.sort(key=lambda p: p.fullName)
|
||||
profiles.sort(key=lambda p: smartSort(p.fullName))
|
||||
|
||||
self.profileEventMap = {}
|
||||
items = (OrderedDict(), OrderedDict())
|
||||
|
||||
@@ -7,6 +7,7 @@ import wx
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenuUnconditional
|
||||
from gui.utils.sorter import smartSort
|
||||
from service.fit import Fit
|
||||
from service.targetProfile import TargetProfile as svc_TargetProfile
|
||||
|
||||
@@ -60,7 +61,7 @@ class TargetProfileSwitcher(ContextMenuUnconditional):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
sTR = svc_TargetProfile.getInstance()
|
||||
profiles = list(chain(sTR.getBuiltinTargetProfileList(), sTR.getUserTargetProfileList()))
|
||||
profiles.sort(key=lambda p: p.fullName)
|
||||
profiles.sort(key=lambda p: smartSort(p.fullName))
|
||||
|
||||
self.profileEventMap = {}
|
||||
items = (OrderedDict(), OrderedDict())
|
||||
|
||||
13
gui/utils/sorter.py
Normal file
13
gui/utils/sorter.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
Taken from https://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
def _convert(text):
|
||||
return int(text) if text.isdigit() else text
|
||||
|
||||
|
||||
def smartSort(key):
|
||||
return [_convert(c) for c in re.split('([0-9]+)', key)]
|
||||
Reference in New Issue
Block a user