In This Article

DataModelSortComparer Class

Provides a comparer implementation for sorting IDataModel objects in order of sort importance, sort order, numeric display name index (if applicable), and finally display name.

public class DataModelSortComparer
Inheritance:
object object

Constructors

DataModelSortComparer()

Initializes an instance of the class.

public DataModelSortComparer()

Properties

CanCompareDisplayName

Indicates whether display name can be compared.

public bool CanCompareDisplayName { get; set; }

Property Value

bool:

true if display name can be compared; otherwise, false. The default value is true.

CanCompareIndex

Indicates whether a numeric index value (e.g. [0]) in the display name can be compared.

public bool CanCompareIndex { get; set; }

Property Value

bool:

true if a numeric index value (e.g. [0]) in the display name can be compared; otherwise, false. The default value is true.

CanCompareSortImportance

Indicates whether sort importance can be compared.

public bool CanCompareSortImportance { get; set; }

Property Value

bool:

true if sort importance can be compared; otherwise, false. The default value is true.

CanCompareSortOrder

Indicates whether sort order can be compared.

public bool CanCompareSortOrder { get; set; }

Property Value

bool:

true if sort order can be compared; otherwise, false. The default value is true.

Methods

Compare(IDataModel?, IDataModel?)

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public virtual int Compare(IDataModel? left, IDataModel? right)
Parameter Type Description
left IDataModel
right IDataModel

Returns

int:

A signed integer that indicates the relative values of x and y, as shown in the following table.

Value Meaning
Less than zerox is less than y.
Zerox equals y.
Greater than zerox is greater than y.

CompareDisplayName(string?, string?)

Compares two DisplayName values and returns a value indicating whether one is less than, equal to or greater than the other.

protected virtual int CompareDisplayName(string? left, string? right)
Parameter Type Description
left string

First object to compare.

right string

Second object to compare.

Returns

int:

A value indicating whether one is less than, equal to or greater than the other.

CompareIndex(string?, string?)

Compares two DisplayName values to see if they contain numeric indices (e.g. [0]) and returns a value indicating whether one is less than, equal to or greater than the other.

protected virtual int CompareIndex(string? left, string? right)
Parameter Type Description
left string

First object to compare.

right string

Second object to compare.

Returns

int:

A value indicating whether one is less than, equal to or greater than the other.

CompareSortImportance(DataModelSortImportance, DataModelSortImportance)

Compares two SortImportance values and returns a value indicating whether one is less than, equal to or greater than the other.

protected virtual int CompareSortImportance(DataModelSortImportance left, DataModelSortImportance right)
Parameter Type Description
left DataModelSortImportance

First object to compare.

right DataModelSortImportance

Second object to compare.

Returns

int:

A value indicating whether one is less than, equal to or greater than the other.

CompareSortOrder(int, int)

Compares two SortOrder values and returns a value indicating whether one is less than, equal to or greater than the other.

protected virtual int CompareSortOrder(int left, int right)
Parameter Type Description
left int

First object to compare.

right int

Second object to compare.

Returns

int:

A value indicating whether one is less than, equal to or greater than the other.

Inherited Members

Extension Methods