Files
tldr/pages.zh/windows/sort-object.md

25 lines
672 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Sort-Object
> 按属性值对对象进行排序。
> 注意:此命令只能通过 PowerShell 使用。
> 更多信息:<https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/sort-object>。
- 按名称对当前目录进行排序:
`Get-ChildItem | Sort-Object`
- 按名称降序对当前目录进行排序:
`Get-ChildItem | Sort-Object -Descending`
- 排序项目并移除重复项:
`"a", "b", "a" | Sort-Object -Unique`
- 按文件长度对当前目录进行排序:
`Get-ChildItem | Sort-Object -Property Length`
- 按工作集WS大小对内存使用最高的进程进行排序
`Get-Process | Sort-Object -Property WS`