ArgSort / Manipulation Layer
Return indices that would sort a column, similar to NumPy's argsort() or R's order(). Instead of actually sorting the data, it returns a column of integer indices indicating the sorted order.
Mathematical definition: For input array x of length n, argsort returns array i where: Or for descending order: Where represents the index at position j in the result.
Example: Input x = [3, 1, 4, 2] Output i = [1, 3, 0, 2] because:
This operation is particularly useful for:
- Indirect sorting and ranking
- Creating custom sort orders
- Tracking original positions after sorting
- Mapping between sorted and unsorted data
- Implementing stable sorting algorithms
Example applications:
- Competition rankings (while preserving original entry numbers)
- Student grade ordering (maintaining student IDs)
- Time series event sequencing
- Priority queue implementation
- Cross-reference between sorted and raw data
The returned indices can be used to reorder this or other columns, enabling complex sorting operations while maintaining data relationships.
Select
columnThe column to determine sort order from. Can contain any sortable type (numeric, string, datetime, etc.). The values in this column define the ordering, but aren't modified - instead, their sorted positions are returned.
Descending
boolControls sort direction:
false
(default): Ascending order (1,2,3 or A,B,C)true
: Descending order (3,2,1 or C,B,A)
Common uses:
- Ascending for natural ordering (timestamps, IDs)
- Descending for rankings (scores, priorities)
NullsLast
boolDetermines null value placement in the sort order:
false
(default): Nulls first (null,1,2,3)true
: Nulls last (1,2,3,null)
Important for:
- Missing data handling
- Incomplete record prioritization
- Data quality sorting
MaintainOrder
boolControls stability of the sort:
false
(default): May reorder equal elementstrue
: Maintains relative order of equal elements (stable sort)
Critical for:
- Multi-pass sorting
- Preserving secondary ordering
- Maintaining data history
- Reproducible results
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.