> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OrderBy gem for Data Analysis

> Sort the data

export const gemName_0 = "OrderBy"

export const execution_engine_0 = "the SQL warehouse"

<Info>This gem runs in {execution_engine_0}.</Info>

## Overview

Sorts a model on one or more columns in ascending or descending order.

<Tip>
  The {gemName_0} gem has a corresponding interactive gem example. See [Interactive gem
  examples](/data-analysis/gems/gems#interactive-gem-examples) to learn how to run sample pipelines
  for this and other gems.
</Tip>

## Parameters

| Parameter     | Description                                | Required |
| ------------- | ------------------------------------------ | -------- |
| Order columns | Columns to sort the model by               | True     |
| Sort          | Order of sorting (ascending or descending) | True     |

## Example

Assume you have the following weather prediction table.

<div class="table-example">
  | DatePrediction | TemperatureCelsius | HumidityPercent | WindSpeed | Condition |
  | -------------- | ------------------ | --------------- | --------- | --------- |
  | 2025-03-01     | 15                 | 65              | 10        | Sunny     |
  | 2025-03-02     | 17                 | 70              | 12        | Cloudy    |
  | 2025-03-03     | 16                 | 68              | 11        | Rainy     |
  | 2025-03-04     | 14                 | 72              | 9         | Sunny     |
</div>

### Result

The follow table results when you order by the `HumidityPercent` column in **ascending** order.

<div class="table-example">
  | DatePrediction | TemperatureCelsius | HumidityPercent | WindSpeed | Condition |
  | -------------- | ------------------ | --------------- | --------- | --------- |
  | 2025-03-01     | 15                 | 65              | 10        | Sunny     |
  | 2025-03-03     | 16                 | 68              | 11        | Rainy     |
  | 2025-03-02     | 17                 | 70              | 12        | Cloudy    |
  | 2025-03-04     | 14                 | 72              | 9         | Sunny     |
</div>
