PowerShell Sort-Object¶
The Sort-Object cmdlet is used in PowerShell to sort output objects based on specific property values^[600-developer-learn-powershell01.md].
Syntax and Usage¶
To sort objects, they can be piped into Sort-Object using the -Property parameter to define the sort key^[600-developer-learn-powershell01.md]. By default, the sort order is ascending, but this can be reversed by using the -Descending switch^[600-developer-learn-powershell01.md].
Examples¶
Sorting processes by their memory usage (PM) from highest to lowest allows for quick identification of resource-intensive applications^[600-developer-learn-powershell01.md].
Get-Process | Sort-Object -Property PM -Descending | Format-Table * -AutoSize
Related Concepts¶
- [[PowerShell]]
- [[Get-Process]]
- [[Format-Table]]
Sources¶
^[600-developer-learn-powershell01.md]