Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The -Ascending parameter sorts the objects in ascending order, which is the default behavior.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The -Descending parameter sorts the strings from Z to A, which is descending order.
3fill in blank
hardFix 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'
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.
✗ Incorrect
Property names are case-sensitive in Sort-Object. 'Name' matches the property exactly.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Ascending sorts in the wrong order.
Using -CaseSensitive is irrelevant for numbers.
Forgetting -Unique keeps duplicates.
✗ Incorrect
Use -Descending to sort from highest to lowest and -Unique to remove duplicates.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up properties and directions.
Not specifying properties correctly.
Using -Ascending on Score instead of -Descending.
✗ Incorrect
First sort by Score property descending, then by Name property ascending.