Sort
Sorts by the "CPU" property:
Get-Process | Sort-Object -Property CPU
Sorts by the "CPU" property, and if two are the same, it sorts by the ID, in descending order:
Get-Process | Sort-Object CPU,ID -desc
Sort files in current dir by creation time:
gci | Select Name,CreationTime | Sort-Object CreationTime -desc
Sorts the lines in a text file and outputs to another file:
sort C:\path\to\file.txt > C:\path\to\sortedfile.txt
Sorts the content of a file alphabetically and saves the sorted content to a new file:
type C:\path\to\file.txt | sort > C:\path\to\sortedfile.txt
Last updated
Was this helpful?