24/7/365 Support

Sort an Array or List of Items

Problem

You want to sort the elements of an array or list.

Solution

To sort a list of items, use the SortObject cmdlet: PS >GetChildItem | SortObject Descending Length | Select Name,Length

Name
Length

ConvertTextObject.ps1
6868

ConnectWebService.ps1
4178

SelectFilteredObject.ps1
3252

GetPageUrls.ps1
2878

GetCharacteristics.ps1
2515

GetAnswer.ps1
1890

NewGenericObject.ps1
1490

InvokeCmdScript.ps1
1313

Discussion

The SortObject cmdlet provides a convenient way for you to sort items by a property that you specify. If you don’t specify a property, the SortObject cmdlet follows the sorting rules of those items if they define any.

In addition to sorting by a property in ascending or descending order, the SortObject cmdlet’s –Unique switch also allows you to remove duplicates from the sorted collection.

For more information about the SortObject cmdlet, type GetHelp SortObject.

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 128 GB (SSD SATA) Configure Server
Intel Atom C2750 2.4 GHz 8c/8t 8 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Xeon E3-1230 v2 3.3 GHz 4c/8t 16 GB DDR3 1× 256 GB (SSD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 250 GB (SSD SATA) Configure Server

What Our Clients Say