Function Sort-List {
param($list)
write "Before sorting"
write "$list"
$len = $list.Count
foreach ($i in $list) {
foreach ($j in @(0..($len -2))) {
if ($list[$j] -gt $list[$j+1]) {
$list[$j],$list[$j+1] = $list[$j+1],$list[$j]
}
}
}
write $("-" * 3)
write "After sorting"
return $list
}
$newlist = @(1..20) | Get-Random -Count 10
write "$(Sort-List $newlist)"