Documentation > CMS Template API Library > SortOrder

CrownPeak.CMSAPI.SortOrder

Represents an order by which assets or panels can be sorted. Allows for multiple levels of sorting on both built-in and custom asset fields.

NameDescriptionType
OrderBy

Creates an ascending sort order on a built-in field.

Method
OrderBy

Creates an ascending sort order on a custom field.

Method
OrderByDescending

Creates a descending sort order on a built-in field.

Method
OrderByDescending

Creates a descending sort order on a custom field.

Method
ThenBy

Adds an additional built-in field to the current sort order in ascending order.

Method
ThenBy

Adds an additional custom field to the current sort order in ascending order.

Method
ThenByDescending

Adds an additional built-in field to the current sort order in descending order.

Method
ThenByDescending

Adds an additional custom field to the current sort order in descending order.

Method

Code Example

C#

Sample:

            // Sort by a built-in field, ascending
            SortOrder order1 = SortOrder.OrderBy(AssetPropertyNames.Label);
            
            // Sort by custom field, descending
            SortOrder order2 = SortOrder.OrderByDescending("field_name");
            
            // Sort by multiple fields
            SortOrder order3 = SortOrder.OrderBy("field_name")
                                        .ThenBy("other_field")
                                        .ThenByDescending(AssetPropertyNames.ModifiedDate);
            

Connect with Crownpeak