Sort-Object
Sort pipeline objects
Get-ChildItem | Sort-Object -Property Length -Descending
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Sort-Object
- PowerShell 7 On Linux and macOS, sort runs the system command instead of this cmdlet. Type the full cmdlet name there.
Sorts by a property. -Descending reverses it. -Unique drops duplicates after sorting.
Try this
Get-Process | Sort-Object -Property WorkingSet -Descending | Select-Object -First 10
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | ls -S |
More in From bash and From cmd.