May 9th, 2014

PowerTip: Sort a PowerShell Array

Doctor Scripto
Scripter

Summary: Learn how to easily sort an array of numbers by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily sort an array of numbers stored in a variable?

Hey, Scripting Guy! Answer Use the Sort static method from the [array] .NET Framework class:

$a = 1,5,3,8,2,12

[array]::sort($a)

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.