---
title: orderBy (WindowSpec)
description: "WindowSpec.orderBy method in PySpark: Defines the ordering columns in a WindowSpec."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/windowspec/orderBy
---

# orderBy (WindowSpec)

Defines the ordering columns in a `WindowSpec`.

## Syntax

```
orderBy(*cols)
```

## Parameters

| Parameter | Type                 | Description                      |
| --------- | -------------------- | -------------------------------- |
| `cols`    | str, Column, or list | Names of columns or expressions. |

## Returns

`WindowSpec`
