PropertyDescriptorCollection.Sort Method

Definition

Sorts the members of this collection.

Overloads

Sort()

Sorts the members of this collection, using the default sort for this collection, which is usually alphabetical.

Sort(IComparer)

Sorts the members of this collection, using the specified IComparer.

Sort(String[])

Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

Sort(String[], IComparer)

Sorts the members of this collection. The specified order is applied first, followed by the sort using the specified IComparer.

Sort()

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Sorts the members of this collection, using the default sort for this collection, which is usually alphabetical.

C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort();

Returns

A new PropertyDescriptorCollection that contains the sorted PropertyDescriptor objects.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Sort(IComparer)

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Sorts the members of this collection, using the specified IComparer.

C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(System.Collections.IComparer? comparer);
C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(System.Collections.IComparer comparer);

Parameters

comparer
IComparer

A comparer to use to sort the PropertyDescriptor objects in this collection.

Returns

A new PropertyDescriptorCollection that contains the sorted PropertyDescriptor objects.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Sort(String[])

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[]? names);
C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names);

Parameters

names
String[]

An array of strings describing the order in which to sort the PropertyDescriptor objects in this collection.

Returns

A new PropertyDescriptorCollection that contains the sorted PropertyDescriptor objects.

Examples

The following code example defines the sort order for the Sort method. If the PropertyDescriptorCollection contains four PropertyDescriptor objects with the names A, B, C, and D, the properties of myNewColl would be sorted in the order D, B, A, and C.

C#
myNewColl = this.Sort(new string[]{"D", "B"});

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Sort(String[], IComparer)

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Sorts the members of this collection. The specified order is applied first, followed by the sort using the specified IComparer.

C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[]? names, System.Collections.IComparer? comparer);
C#
public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer);

Parameters

names
String[]

An array of strings describing the order in which to sort the PropertyDescriptor objects in this collection.

comparer
IComparer

A comparer to use to sort the PropertyDescriptor objects in this collection.

Returns

A new PropertyDescriptorCollection that contains the sorted PropertyDescriptor objects.

Examples

The following code example defines the sort order for the Sort method. If the PropertyDescriptorCollection contains four PropertyDescriptor objects with the names A, B, C, and D, the properties of myNewColl would be sorted in the order D, B, A, and C.

C#
myNewColl = this.Sort(new string[]{"D", "B"});

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1