Created
March 20, 2014 00:31
-
-
Save wolf0403/9654833 to your computer and use it in GitHub Desktop.
sort "du -h" output.
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 cmpsz(s1, s2): | |
tosz = lambda s: ('KMG'.find(s[-1]), float(s[:-1]) if s[-1] in 'KMG' else float(s)) | |
u1, s1 = tosz(s1) | |
u2, s2 = tosz(s2) | |
scmp = cmp(u1, u2) | |
return scmp if scmp != 0 else cmp(s1, s2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment