Skip to main content

Sorts objects by property values.

# To sort the current directory by name:
Get-ChildItem | Sort-Object

# To sort the current directory by name descending:
Get-ChildItem | Sort-Object -Descending

# To sort items removing duplicates:
"a", "b", "a" | Sort-Object -Unique

# To sort the current directory by file length:
Get-ChildItem | Sort-Object -Property Length

# To sort processes with the highest memory usage based on their working set (WS) size:
Get-Process | Sort-Object -Property WS