订购排序对象排序
按升序或降序对枚举进行排序
别名:
Sort-Object
sort
假设:
$names = @( "Aaron", "Aaron", "Bernie", "Charlie", "Danny" )
升序排序是默认值:
$names | Sort-Object
$names | sort
Aaron
Aaron
Bernie
Charlie
Danny
要求降序:
$names | Sort-Object -Descending
$names | sort -Descending
Danny
Charlie
Bernie
Aaron
Aaron
你可以使用表达式排序。
$names | Sort-Object { $_.length }
Aaron
Aaron
Danny
Bernie
Charlie