# sort_values()

*noun*

say it: **“SORT VAL-yooz”** **/ˈsɔrt ˈvæljuz/**

A pandas method that puts a table's rows in order by the values in one or more columns, smallest first unless told otherwise.

## What does **sort_values()** do in pandas?

**sort_values()** is the pandas method that hands back a table with its rows in order by one column, or by several,
with `ascending=` saying which way each one goes. It puts the smallest first unless you say otherwise.

```python
import pandas as pd
products = pd.DataFrame({"name": ["Trail Boot", "Rain Jacket", "Camp Stove"],
                         "rating": [4.6, 4.8, 4.6], "reviews": [210, 95, 340]})
best = products.sort_values(["rating", "reviews"], ascending=[False, False])
print(best["name"].tolist())   # ['Rain Jacket', 'Camp Stove', 'Trail Boot']
```

## In a sentence

- “**sort_values()** put the best-rated products at the top.”
- “She used **sort_values()** with ascending=False to list the biggest orders first.”

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/sort-values
