Skip to main content

How to Sort Runs in the MLflow UI

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

The MLflow runs table lists the newest run first. To put the best run on top instead, sort the table by the metric that measures it: lowest loss first, or highest accuracy first. This guide sorts four runs by a metric and by a parameter, where text ordering produces a surprise, and by clicking a column header, with real screens from MLflow 3.18.0.

Prerequisites​

Step 1: Create Four Runs to Sort​

The example is four training runs with different batch sizes, each with the loss it ended at. Create batch_runs.py:

batch_runs.py
import mlflow

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("ui-sort-demo")

for name, batch_size, loss in [
("tiny-batch", 8, 0.42),
("small-batch", 16, 0.35),
("big-batch", 64, 0.31),
("huge-batch", 128, 0.38),
]:
with mlflow.start_run(run_name=name):
mlflow.log_param("batch_size", batch_size)
mlflow.log_metric("loss", loss)
Terminal
uv run python batch_runs.py

The script prints a View run link for each run and a View experiment link. Open the experiment, ui-sort-demo, in the UI. I added the loss and batch_size columns with the Columns button so the values show in the table.

Step 2: Open the Sort Menu​

Click Sort: Created in the toolbar:

The open sort menu of the ui-sort-demo runs table: the button reads Sort: Created; inside the menu are a Search box, a down-arrow button that is selected and an up-arrow button, and the options Created (ticked), User, Run Name, Source, Version, Description, loss and batch_size.

PartWhat it does
SearchNarrows the list when an experiment has many metrics and parameters
↓, "Sort descending"Highest value first: the newest run, for Created
↑, "Sort ascending"Lowest value first
The listWhat to sort by: the run's own fields, then every metric and parameter the experiment's runs logged

Step 3: Sort by a Metric​

A lower loss is better, so the best run comes first in ascending order. Click ↑; the order changes at once and the menu closes. Open it again and click loss:

The ui-sort-demo runs table sorted by loss from lowest to highest: big-batch 0.31, small-batch 0.35, huge-batch 0.38 and tiny-batch 0.42, with the button reading Sort: loss and an up-arrow next to the loss column header.

big-batch is on top with 0.31. The button reads Sort: loss, and the loss column shows the sort arrow. For a metric where higher is better, such as accuracy, choose ↓ instead.

Step 4: Sort by a Parameter​

Open the menu and click batch_size, still ascending:

The ui-sort-demo runs table sorted by batch_size ascending: huge-batch with 128 first, then small-batch 16, big-batch 64 and tiny-batch 8 last.

The order is 128, 16, 64, 8, not 8, 16, 64, 128. MLflow stores every parameter as text, so it sorts parameters the way a dictionary sorts words, character by character: 1 comes before 6 and 8, and 128 comes before 16 because 2 comes before 6. Metrics are numbers and sort by value.

Read a parameter column sorted this way as alphabetical. When the numeric order of a setting matters, sort by the metric that setting affects, as in Step 3.

Step 5: Sort by Clicking a Column Header​

Clicking a column's header, such as loss, sorts the table by that column. Clicking the same header again reverses the order.

Common Mistakes​

MistakeWhat happensDo this instead
Picking a metric with ↓ still selected, when lower is betterThe worst run is on topClick ↑ for loss and error metrics
Expecting a parameter column to sort as numbers128 comes before 16Remember parameters are text; sort by a metric for numeric order
Clicking the arrow and expecting the menu to stay openIt applies the direction to the current sort and closesOpen the menu again to pick the column

Troubleshooting​

SymptomLikely causeFix
A metric or parameter isn't in the sort listNone of the runs in the table logged itCheck its exact name on a run's Overview
The best run isn't firstThe direction is the wrong way round for this metricSwitch between ↑ and ↓

FAQ​

Where do runs without the value go?​

Last, whichever direction you choose. In a runs table sorted by a metric that some runs never logged, those runs are listed after all the others.

Can I sort by two columns?​

The menu sorts by one column at a time. In Python, mlflow.search_runs() accepts several, such as order_by=["metrics.loss ASC", "attributes.start_time DESC"].

Is the sort saved?​

It's part of the page's address, as orderByKey and orderByAsc, so a bookmark or a shared link opens with the same order.

Conclusion​

Sort orders the runs table by any run field, metric or parameter: ↑ for lowest first, ↓ for highest first, and a column header click does the same and reverses on a second click. Metrics sort by value, while parameters sort as text, so 128 comes before 16.

Additional Resources​

  • Search Runs — MLflow's guide, including how ordering works in its Python API.