function SortGroupByCount($o) { $o.GetEnumerator() | group | sort Count -d | select Group | %{ Write-Host -n "$($_.Group) " } }
> SortGroupByCount "Hello world" l l l o o H e w r d > SortGroupByCount 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6 3 3 3 3 5 5 5 9 9 9 1 1 4 4 2 2 6 6 8 8 7