PowerTip of the Day-Sorting Multiple Properties
原文地址:http://app.en25.com/e/es.aspx?s=1403&e=4571&elq=535d59530c004cd899a9c0ff03da88a4
原文:
Sort-Object can sort on multiple properties at the same time. Have a look:
Get-Service | Sort-Object Status, Name
This will list stopped services first, then running services. Within the two blocks, services are sorted by name. To reverse sort order, you can add -Descending. Then, however, both properties would be sorted in descending order. Here is how you can specify sort order individually:
$prop1 = @{Expression='Status'; Descending=$true }
$prop2 = @{Expression='Name'; Ascending=$true }
Get-Service | Sort-Object $prop1, $prop2
翻译:
Sort-Object可以对多个属性同时指定排序,比如:
Get-Service | Sort-Object Status, Name
这个命令会先列出停止运行的服务,然后列出正在运行的服务。在这两组里,服务列表又是根据服务名称排序的。如果要反转排序顺序,可以加入-Descending。但这样,两个属性都会根据这个规则降序排序。以下是一种分别指定排序规则的方法:
$prop1 = @{Expression='Status'; Descending=$true }
$prop2 = @{Expression='Name'; Ascending=$true }
Get-Service | Sort-Object $prop1, $prop2
笔记:
定义列的时候可以分别对其指定排序规则。
---------------------------------------------------------------
aspnetx的BI笔记系列索引:
使用SQL Server Analysis Services数据挖掘的关联规则实现商品推荐功能
---------------------------------------------------------------