How to sort by size of output by du -sh ~/* | sort -r

Solution 1:

This worked.

du -sh ~/* | sort -rh

sort has -h flag:

-h, --human-numeric-sort, --sort=human-numeric
             Sort by numerical value, but take into account the SI suffix, if present.
...