sort_data
Sort CSV data by single or multiple columns with flexible direction control and comprehensive error handling to maintain data integrity.
Instructions
Sort data by one or more columns with comprehensive error handling.
Provides flexible sorting capabilities with support for multiple columns and sort directions. Handles mixed data types appropriately and maintains data integrity throughout the sorting process.
Examples: # Simple single column sort sort_data(ctx, ["age"])
# Multi-column sort with different directions
sort_data(ctx, [
{"column": "department", "ascending": True},
{"column": "salary", "ascending": False}
])
# Using SortColumn objects for type safety
sort_data(ctx, [
SortColumn(column="name", ascending=True),
SortColumn(column="age", ascending=False)
])Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| columns | Yes | Column specifications for sorting (strings or SortColumn objects) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | Whether operation completed successfully | |
| ascending | Yes | Sort direction for each column (True=ascending, False=descending) | |
| sorted_by | Yes | Column names used for sorting | |
| rows_processed | Yes | Number of rows that were sorted |