0
0
PowerShellscripting~10 mins

Sort-Object for ordering in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to sort the numbers in ascending order.

PowerShell
1, 5, 3, 2, 4 | Sort-Object [1]
Drag options to blanks, or click blank then click option'
A-Ascending
B-Descending
C-Unique
D-CaseSensitive
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Descending will sort in reverse order.
Using -Unique removes duplicates but does not sort.
Using -CaseSensitive is for string comparison, not sorting order.
2fill in blank
medium

Complete the code to sort a list of strings in descending order.

PowerShell
'apple', 'banana', 'cherry' | Sort-Object [1]
Drag options to blanks, or click blank then click option'
A-Unique
B-CaseSensitive
C-Descending
D-IgnoreCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Unique does not affect order but removes duplicates.
Using -CaseSensitive changes how letters are compared but not order direction.
Using -IgnoreCase affects case sensitivity, not order direction.
3fill in blank
hard

Fix the error in the code to sort objects by the 'Name' property in ascending order.

PowerShell
$users | Sort-Object -Property [1]
Drag options to blanks, or click blank then click option'
AAge
Bname
Cusername
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' with lowercase n causes no sorting because property not found.
Using unrelated property names like 'Age' or 'username' sorts by wrong property.
4fill in blank
hard

Fill both blanks to sort the list of numbers in descending order and remove duplicates.

PowerShell
5, 3, 5, 2, 3 | Sort-Object [1] [2]
Drag options to blanks, or click blank then click option'
A-Descending
B-Unique
C-Ascending
D-CaseSensitive
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Ascending sorts in the wrong order.
Using -CaseSensitive is irrelevant for numbers.
Forgetting -Unique keeps duplicates.
5fill in blank
hard

Fill all three blanks to sort a list of objects by 'Score' descending, then by 'Name' ascending.

PowerShell
$players | Sort-Object [1] [2] [3]
Drag options to blanks, or click blank then click option'
A-Property Score
B-Descending
C-Property Name
D-Ascending
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up properties and directions.
Not specifying properties correctly.
Using -Ascending on Score instead of -Descending.