Last active
December 15, 2015 12:49
-
-
Save glyphobet/5262639 to your computer and use it in GitHub Desktop.
Sort size letters like XS, S, M, L, XL, LL, XXL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def size_cmp(sizea, sizeb): | |
return cmp(size_value(sizea), size_value(sizeb)) | |
def size_value(size): | |
size = size.upper() | |
return (size.count('L') - size.count('S')) * (size.count('X') + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment