Say you want to sort the output of “ls” (Get-ChildItem) according to file size, date modified or alphabetically, try:
1. Sort according to file size:
ls | sort -property Length
2. Sort according to data modified:
ls | sort -property LastWriteTime
3. Sort according to Name:
ls | sort -property Name
To return a descending list, just add -descending at the back. This applies any stdout pipes, not just Get-ChildItem.
I’ve piped an object to select *, how to I get the output so that the properties of the object are sorted?
When you pipe the properties, it should be a collection with property names like “Name, Date Modified” etc. Then just sort using sort -property [PropertyName]