Skip to content

Instantly share code, notes, and snippets.

@teionn
Last active December 9, 2017 19:37
Show Gist options
  • Save teionn/9e670368fabd5c8fefd53a2e36290dd0 to your computer and use it in GitHub Desktop.
Save teionn/9e670368fabd5c8fefd53a2e36290dd0 to your computer and use it in GitHub Desktop.
import re
from collections import OrderedDict
def sortedStringList(array=[]):
sortDict=OrderedDict()
for splitList in array:
sortDict.update({splitList:[int(x) for x in re.split("(\d+)",splitList)if bool(re.match("\d*",x).group())]})
return [sortObjKey for sortObjKey,sortObjValue in sorted(sortDict.items(), key=lambda x:x[1])]
getList=["test_20_geo","test_100_geo","test_001_geo","test_10_geo","test_011_geo","test_2_geo"]
print sortedStringList(getList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment