Hello guys,
I’m looking for a PowerShell one liner doing the same as “sort | uniq -c | sort -nr” on a Unix shell.
Using for example
@(55,22,33,44,11,44,33,22,11,33,22,11,22,11,11) | group-object | format-table -h count,name
will deliver
1 55
4 22
3 33
2 44
5 11
But the goal is to have this list sorted by frequency in descending order.
Trying
@(55,22,33,44,11,44,33,22,11,33,22,11,22,11,11) | group-object | format-table -h count,name | sort-object -descending
doesn’t work.
Using a temporary file will do the job but this is not an elegant solution.
@(55,22,33,44,11,44,33,22,11,33,22,11,22,11,11) | group-object | format-table -h count,name >tmp
get-content tmp | sort-object -descending
5 11
4 22
3 33
2 44
1 55
Anybody to propose a clean and straightforward way to execute such task in PowerShell just like in the Unix shell?