Sorting
Sorting organizes your data in a meaningful order, making it easier to analyze and present. Visitran's No-Code UI allows you to sort by one or more columns with just a few clicks.
Overview
Sorting arranges rows in your dataset based on the values in one or more columns. You can sort in ascending (A-Z, 0-9, oldest to newest) or descending (Z-A, 9-0, newest to oldest) order.
Sort Order Options
Ascending (ASC)
Orders data from lowest to highest value.
Examples:
- Numbers: 1, 2, 3, 10, 100
- Text: A, B, C, ... Z
- Dates: Oldest to newest
Descending (DESC)
Orders data from highest to lowest value.
Examples:
- Numbers: 100, 10, 3, 2, 1
- Text: Z, Y, X, ... A
- Dates: Newest to oldest
How to Sort in Visitran
Step-by-Step Instructions
- Select Your Model - Navigate to the model you want to sort
- Add Sort Operation - Click "Add Sort" or click on a column header
- Choose Sort Column - Select the column to sort by
- Select Sort Direction - Choose ascending or descending
- Add Additional Sorts - Optionally add secondary sort columns
- Preview Results - View the sorted data in the data grid
- Save - Apply the changes to your model
Single Column Sort
Sort by one column to organize data by a single dimension.
Example: Sort customers by last name alphabetically.
Multi-Column Sort
Sort by multiple columns to create hierarchical ordering.
Example: Sort by region (ascending), then by sales (descending) within each region.
Common Use Cases
Sales Reports
Sort By:
1. region (ASC) - Group by region
2. total_sales (DESC) - Show top performers first within each region
Customer Lists
Sort By:
1. last_name (ASC)
2. first_name (ASC)
Transaction History
Sort By:
1. transaction_date (DESC) - Most recent first
2. amount (DESC) - Highest amounts first for same date
Product Inventory
Sort By:
1. category (ASC)
2. stock_level (ASC) - Show items needing restock first
Data Type Sorting Behavior
Numeric Values
- Sorted mathematically (1, 2, 10, 20 not 1, 10, 2, 20)
- NULL values typically appear first (ascending) or last (descending)
Text Values
- Sorted lexicographically (dictionary order)
- Case-sensitivity depends on database collation
- Special characters sorted based on character code
Date/Time Values
- Sorted chronologically
- NULL values represent missing dates
Boolean Values
- FALSE typically comes before TRUE
- Or sorted as 0/1 numerically
Best Practices
- Sort Early - Apply sorting as late as possible in your transformation pipeline for better performance
- Use Indexes - Ensure sorted columns are indexed for faster queries
- Limit Results - Consider limiting rows when sorting large datasets
- Document Sort Logic - Explain why specific sort orders are chosen
- Consider NULL Handling - Decide how NULL values should be ordered
Performance Considerations
- Index Sorted Columns - Significantly improves sort performance
- Limit Sorted Rows - Sorting fewer rows is faster
- Avoid Sorting Large Text - Sorting on long text fields can be slow
- Consider Clustered Indexes - Pre-sort data physically on disk
Multi-Level Sorting
When sorting by multiple columns, the order matters:
- Primary Sort - First column defines main grouping
- Secondary Sort - Applied within primary sort groups
- Tertiary Sort - Applied within secondary sort groups
Example:
Sort By:
1. country (ASC) → Groups by country
2. state (ASC) → Groups by state within country
3. city (ASC) → Alphabetical within state
4. last_name (ASC) → Alphabetical within city
Troubleshooting
Unexpected Sort Order
- Check for leading/trailing spaces in text
- Verify data types are correct
- Review NULL value handling
- Check database collation settings
Performance Issues
- Add indexes on frequently sorted columns
- Reduce the number of rows being sorted
- Consider pre-sorting in earlier pipeline stages
- Evaluate need for multiple sort columns
Mixed Data Types
- Ensure columns contain consistent data types
- Handle NULL values appropriately
- Consider converting data types before sorting
Related Operations
- Adding Aggregations - Sort aggregated results
- Unique / Distinct - Sort after removing duplicates
- Showing / Hiding Columns - Focus on relevant sorted columns
Sorting vs. Filtering
| Sorting | Filtering |
|---|---|
| Changes row order | Removes rows |
| Shows all data | Shows subset |
| For presentation | For analysis |
Detailed screenshots showing the sorting interface will be added soon.