http://www.perlmonks.org?node_id=746401


in reply to Re: du -h, sorted
in thread du -h, sorted

I like your subtle omission of parens from h$a, versus h($b). But to sort correctly, I tweaked slightly to use the OP's 10,20,30 values.
perl -e 'sub h{pop=~/(...)(.)/&&$1*2**{K,10,M,20,G,30}->{$2}}print sor +t{h($b)<=>h$a}`du -h`'