0
0
PowerShellscripting~20 mins

Sort-Object for ordering in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sort-Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Sort-Object command?
Given this PowerShell command, what will be the output?
PowerShell
1..5 | Sort-Object -Descending
AError: Parameter set cannot be resolved
B1 2 3 4 5
C5 4 3 2 1
D5 3 1 2 4
Attempts:
2 left
💡 Hint
Think about what -Descending does to a list of numbers.
💻 Command Output
intermediate
2:00remaining
What does this Sort-Object command output?
What is the output of this command?
PowerShell
'apple','banana','cherry' | Sort-Object Length
Aapple banana cherry
Bbanana cherry apple
Capple cherry banana
Dcherry apple banana
Attempts:
2 left
💡 Hint
Sort by the length of each word from shortest to longest.
📝 Syntax
advanced
2:00remaining
Which option correctly sorts objects by a property in descending order?
You have objects with a property 'Age'. Which command sorts them descending by Age?
PowerShell
$people = @(@{Name='Ann';Age=30}, @{Name='Bob';Age=25}, @{Name='Cara';Age=35})
A$people | Sort-Object -Property Age -Descending
B$people | Sort-Object Age Descending
C$people | Sort-Object -Age -Descending
D$people | Sort-Object -Property Age Desc
Attempts:
2 left
💡 Hint
Check the correct syntax for Sort-Object parameters.
🚀 Application
advanced
2:00remaining
How to sort files by LastWriteTime descending?
You want to list files sorted by last modified date, newest first. Which command works?
PowerShell
Get-ChildItem | ???
ASort-Object -Property LastWriteTime Desc
BSort-Object LastWriteTime Descending
CSort-Object -LastWriteTime -Descending
DSort-Object -Property LastWriteTime -Descending
Attempts:
2 left
💡 Hint
Use the correct parameter names and switches for Sort-Object.
🧠 Conceptual
expert
2:00remaining
What error does this Sort-Object command raise?
What error occurs when running this command?
PowerShell
1..5 | Sort-Object -Property NonExistentProperty
ANo error, outputs original list
BPropertyNotFoundException
CSyntaxError
DNullReferenceException
Attempts:
2 left
💡 Hint
Think about what happens if you sort by a property that does not exist.