Edilitics | Data to Decisions

Sort / Order By

Sort your dataset by one or more columns in ascending or descending order. Add multiple sort keys and control precedence across numeric and text columns.

Sort / Order By reorders every row in your dataset based on the values in one or more columns. Set a column as the primary sort key, choose ascending or descending, and add secondary sort keys to break ties. The sort is applied to the full dataset, not just the preview.

Numeric, string, and datetime columns are all supported.


When to Use Sort / Order By

  • Preparing data for ranked reports. Sort by revenue descending to get the top customers or products at the top of the output.
  • Chronological ordering. Sort by a date or datetime column ascending to put the earliest records first, which is expected by most time-series tools.
  • Tiebreaker sorting. Sort first by region, then by sales descending within each region. The secondary key handles rows where the primary key has the same value.
  • Consistent output for joins or exports. Some downstream systems expect rows in a predictable order. Apply a sort before the export step.
  • Leaderboard or ranking preparation. Sort by score descending, then by name ascending as the tiebreaker, before adding a rank column with a Window Function.

Sample Dataset

The examples in this doc use the Edilitics sample orders dataset. Download it to follow along in your own workspace.

edilitics_sample_orders.csv

Sample orders dataset for hands-on practice · 500 rows

Download

Relevant columns for Sort examples:

Prop

Type


How Sort Precedence Works

When you add multiple sort keys, the order of the rows in the configuration panel determines which sort is applied first.

  • Row 1 (primary key): sorts the entire dataset.
  • Row 2 (secondary key): sorts rows that have the same value in row 1. It does not re-sort rows with different primary key values.
  • Row 3 and beyond: each additional key breaks ties left over from the previous keys.

Example: primary key = region ascending, secondary key = revenue descending.

regionrevenueSorted result
East500East rows first, sorted by revenue highest to lowest
East300East rows first, sorted by revenue highest to lowest
West800West rows after, sorted by revenue highest to lowest
West200West rows after, sorted by revenue highest to lowest

The same column cannot be used as both a primary and secondary key. Once a column is selected in one row, it is removed from the dropdown in all other rows.


How to Apply Sort / Order By

Open the Sort / Order By operation

In your Transform pipeline, click Add Operation and select Sort / Order By from the operation list.

Configure the primary sort key

The first row is your primary sort key. It has three fields:

  • Order of Precedence: auto-assigned based on row position. Row 1 = primary, row 2 = secondary, and so on. Cannot be changed manually.
  • Column Name: select the column to sort by. Numeric, string, and datetime columns are all available.
  • Sort Direction: choose Ascending (A to Z, 0 to 9, oldest to newest) or Descending (Z to A, 9 to 0, newest to oldest).

Add secondary sort keys (optional)

Click Add Column to add another sort key row. Select the column and direction. The precedence number updates automatically.

The Add Column button is disabled until the current row has both a column and a direction selected. A column already used in one row will not appear in the dropdown for other rows.

Remove a sort key (optional)

Click the remove icon on any row to delete it. The remove icon only appears when more than one row exists. The first row cannot be removed.

Save the operation

Click Save & Preview. Edilitics sorts the full dataset by your configured keys in order. A success toast confirms: "Sort applied. Preview now reflects ordered rows."

Verify in the preview

Check the data preview to confirm rows appear in the expected order. If the sort direction is wrong, remove the operation and re-add with the corrected direction.


Before and After

Two sort keys: region ascending (primary), revenue descending (secondary).

Before:

regionrevenuecustomer_name
West200Carol White
East300Bob Smith
East500Alice Johnson
West800David Lee

After:

regionrevenuecustomer_name
East500Alice Johnson
East300Bob Smith
West800David Lee
West200Carol White

East rows come first (ascending), within East the higher revenue comes first (descending). Same pattern for West.


Code Equivalent

SELECT *
FROM orders
ORDER BY
  region    ASC,
  revenue   DESC;
import polars as pl

# Multi-column sort in Polars: pass lists to sort()
df = df.sort(
    by=["region", "revenue"],
    descending=[False, True]   # False = ascending, True = descending
)

Note: Edilitics applies sorts sequentially (df.sort() per column) rather than as a single multi-key sort call. The result is equivalent for standard sort use cases.


After Save & Preview, the pipeline shows a DQ delta badge on this step - green if the table score improved, red if it dropped. See Data Quality Scoring for how scores are calculated.


After Save & Preview, the pipeline shows a DQ delta badge on this step - green if the table score improved, red if it dropped. See Data Quality Scoring for how scores are calculated.


Operation Reference

Prop

Type


Frequently Asked Questions


Next Steps

Need help? Email support@edilitics.com with your workspace, job ID, and context. We reply within one business day.

Last updated on

On this page