#test.ps1
#为什么我总觉得它在按字典序排列? 我想让它用数字方式排列
#测试用例:
#How many numbers: 5
#Number0: 123421
#Number1: 1211111
#Number2: 12111101
#Number3: 10
#Number4: 13
$n = Read-Host 'How many strings'
$i = 0
[System.Collections.ArrayList] $a = @()
function PLsort($l, $r) {
if ($l -gt $r) {
return
}
$i = $l
$j = $r
$temp = $a[$l]
while ($i -ne $j) {
while ( ( $a[$j] -ge $temp) -and ($i -lt $j)) {
$j--
}
while ( ( $a[$i] -le $temp) -and ($i -lt $j)) {
$i++
}
if ($i -lt $j) {
$t = $a[$i]
$a[$i] = $a[$j]
$a[$j] = $t
}
}
$a[$l] = $a[$i]
$a[$i] = $temp
$str = ''
for ($p = $l; $p -le $r; $p++) {
$str += $a[$p] + ' '
}
Write-Host $str
PLsort $l ($i - 1)
PLsort ($i + 1) $r
}
while ($i -lt $n) {
$tmp = Read-Host Number$i
$null = $a.Add(@($tmp))
$i++
}
PLsort 0 ($n - 1)
$a