Answered by:
powershell Sort

Question
-
Hi All ,
Could you please explain how we are getting below output ?
$list='one','two','two','three','four','five'
$list |sort
five
four
one
three
two
two- Moved by Dave PatrickMVP Friday, April 24, 2020 1:11 PM looking for forum
Friday, April 24, 2020 12:53 PM
Answers
-
I'd try asking for help over here.
https://social.technet.microsoft.com/Forums/en-US/home?forum=winserverpowershell
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by pituachMVP Friday, April 24, 2020 6:06 PM
- Marked as answer by Dave PatrickMVP Tuesday, May 12, 2020 5:11 PM
Friday, April 24, 2020 1:11 PM
All replies
-
I'd try asking for help over here.
https://social.technet.microsoft.com/Forums/en-US/home?forum=winserverpowershell
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by pituachMVP Friday, April 24, 2020 6:06 PM
- Marked as answer by Dave PatrickMVP Tuesday, May 12, 2020 5:11 PM
Friday, April 24, 2020 1:11 PM -
You have a list of strings, and it is sorted alphabetically.
Richard Mueller - MVP Enterprise Mobility (Identity and Access)
Friday, April 24, 2020 1:35 PM -
Hi All ,
Could you please explain how we are getting below output ?
$list='one','two','two','three','four','five'
$list |sort
five
four
one
three
two
twoYou are storing the values in $list array and then sorting it while displaying with Sort command.
See these:
https://devblogs.microsoft.com/scripting/add-modify-verify-and-sort-your-powershell-array/
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/sort-object?view=powershell-7If the response helped, do "Mark as answer" and upvote it
- VaibhavSaturday, April 25, 2020 2:11 PM