Reorders dataset records based on one or more columns in ascending or descending order. Provides flexible sorting capabilities with multiple notation options.
When to Use
Create rank-ordered views of data
Prepare data for reporting or visualization where order matters
Group similar values together
Find highest/lowest values in specific columns
Implement custom sorting logic for dashboards or exports
How It Works
Normalizes various sorting specifications into a standardized format
Creates a custom comparison function based on sort specifications
Applies PHP's usort() to reorder the entire dataset
Handles special cases like null values, mixed data types, and case-insensitivity
Tracks sorting metadata in extras
Parameters
Required
by - Specifies sorting criteria using one of the following formats:
String: Single column name (e.g., "last_name")
Array of strings: Multiple columns with optional descending prefix (e.g., ["last_name", "-age"])