0
0
PowerShellscripting~5 mins

Sort-Object for ordering in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell cmdlet <code>Sort-Object</code> do?

Sort-Object arranges items in a list or collection in order, either ascending or descending.

Click to reveal answer
beginner
How do you sort a list of numbers in descending order using Sort-Object?

Use the -Descending switch. Example: 1,5,3 | Sort-Object -Descending outputs 5 3 1.

Click to reveal answer
beginner
What parameter do you use with Sort-Object to sort by a property name?

Use the -Property parameter followed by the property name. Example: Get-Process | Sort-Object -Property CPU.

Click to reveal answer
intermediate
Can Sort-Object sort by multiple properties? How?

Yes. Provide an array of property names to -Property. Example: Get-Process | Sort-Object -Property CPU, ID.

Click to reveal answer
beginner
What happens if you use Sort-Object without any parameters?

It sorts the input objects by their default property or value in ascending order.

Click to reveal answer
Which switch sorts objects in descending order with Sort-Object?
A-Order
B-Ascend
C-Reverse
D-Descending
How do you sort a list of strings alphabetically using Sort-Object?
AUse <code>Sort-Object -Descending</code>
BUse <code>Sort-Object -Property Length</code>
CUse <code>Sort-Object</code> without parameters
DUse <code>Sort-Object -Property Count</code>
What does this command do? Get-Process | Sort-Object -Property CPU, ID
ASorts processes by CPU usage, then by ID
BSorts processes by ID only
CSorts processes by CPU usage descending
DSorts processes randomly
If you want to sort numbers from smallest to largest, which parameter do you need?
ANo parameter needed
B-Descending
C-Ascending
D-Reverse
What type of input can Sort-Object sort?
AOnly numbers
BAny objects with properties or values
COnly strings
DOnly files
Explain how to sort a list of objects by multiple properties using Sort-Object.
Think about how you can give more than one property name to Sort-Object.
You got /3 concepts.
    Describe the default behavior of Sort-Object when no parameters are given.
    What happens if you just pipe a list to Sort-Object without extra options?
    You got /3 concepts.