October 2nd, 2014

PowerTip: Use PowerShell to Reverse Array

Doctor Scripto
Scripter

Summary: Easily use Windows PowerShell to reverse an array.

Hey, Scripting Guy! Question How can I use Windows PowerShell to reverse an array?

Hey, Scripting Guy! Answer Pipe the array to the Sort-Object cmdlet and use the –Descending switch, for example:

$a = 1,2,3,4,5

$b = $a | sort -Descending

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.

Feedback