[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Collapse]Card View
   [Expand]Product Information
    Getting Started
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Focus and Navigation
    [Expand]Data Editing
    [Collapse]Data Shaping and Manipulation
     [Expand]Grouping
     [Expand]Data Summaries
     [Expand]Filtering
     [Collapse]Sorting
       Sorting at Runtime
       Sorting in Code
    [Expand]Data Formatting
     Appearance Customization
     Adaptivity
     Save and Restore Layout
    [Expand]Templates
    [Expand]Export
     Toolbars
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Sorting in Code

Expanded Server

To apply sorting to a column(s), use one of the following methods.

The following sample code sorts data against the Contact Name column in ascending order.

The number of columns involved in sorting is returned by the ASPxGridBase.SortCount property. The column's position among sorted columns is specified by the CardViewColumn.SortIndex property.

To remove sorting, do one of the following.

To clear sorting applied to ASPxCardView, call the ASPxGridBase.ClearSort method.

Expanded Client

Use the ASPxClientCardView.SortBy client method to sort data by the values of the specified data column.

To prevent data from being sorted by the values of particular columns, handle the ASPxClientCardView.ColumnSorting client event. The processed client column is identified by the event parameter's column property. To cancel sorting, set the cancel property to true.

Is this topic helpful?​​​​​​​