Powertip Of The Day-sorting multiple properties

Source: Internet
Author: User
Tags sorted by name

Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4571 & elq = 535d59530c004cd899a9c0ff03da88a4

Original article:

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 wocould 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

 

Translation:

Sort-ObjectYou can specify sorting for multiple attributes at the same time, for example:

Get-service | sort-object status, name

This command first lists the stopped services and then lists the running services. In these two groups, the Service list is sorted by service name. If you want to reverse the sorting order, you can add-Descending. In this way, both attributes are sorted in descending order according to the rule. The following is a method for specifying sorting rules:

$ Prop1 =@{ expression = 'status'; descending = $ true}

$ Prop2 =@ {expression = 'name'; ascending = $ true}

Get-service | sort-object $ prop1, $ prop2

 

 

 

Notes:

You can specify sorting rules for a column when defining it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.