---
schema_version: "1"
id: f77f83ead071d63b4696ab5f51a10d71d89fdac85c63b977831e611ce85cd169
title: Order Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_DataSource_Order.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6b81c850ffdc3a7498b1e818cec68014cb9646208842b2886b97369e974145e0
description: Contains details about how to sort the rows in the result set. Equivalent to an ORDER BY statement in a SOQL query.Name of the column whose values are used to sort the rows in the result set.Direction for sorting rows based on column values.Name of the table whose column values are used to sort the rows in the result set.Creates an instance of the DataSource.Order class.
---
# Order Class

Contains details about how to sort the rows in the result set. Equivalent to an ORDER BY statement in a SOQL query.

## Namespace

[DataSource](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_DataSource.htm "The DataSource namespace provides the classes for the Apex Connector Framework. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Then connect your Salesforce organization to any data anywhere via the Salesforce Connect custom adapter.")

## Usage

Used in the [order](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_TableSelection.htm#apex_DataSource_TableSelection_order "Identifies the order for sorting the query results. Corresponds to the ORDER BY clause in a SOQL or SOSL query.") property on the [DataSource.TableSelection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_TableSelection.htm#apex_class_DataSource_TableSelection "Contains a breakdown of the SOQL or SOSL query. Its properties represent the FROM, ORDER BY, SELECT, and WHERE clauses in the query.") class.

- **[Order Properties](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_properties)**
- **[Order Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_methods)**

## Order Properties

The following are properties for Order.

- **[columnName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_columnName)**  
    Name of the column whose values are used to sort the rows in the result set.
- **[direction](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_direction)**  
    Direction for sorting rows based on column values.
- **[tableName](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_tableName)**  
    Name of the table whose column values are used to sort the rows in the result set.

### columnName

Name of the column whose values are used to sort the rows in the result set.

#### Signature

public String columnName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### direction

Direction for sorting rows based on column values.

#### Signature

public DataSource.OrderDirection direction {get; set;}

#### Property Value

Type: [DataSource.OrderDirection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_DataSource_OrderDirection.htm "Specifies the direction for sorting rows based on column values.")

### tableName

Name of the table whose column values are used to sort the rows in the result set.

#### Signature

public String tableName {get; set;}

#### Property Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

## Order Methods

The following are methods for Order.

- **[get(tableName, columnName, direction)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_DataSource_Order.htm#apex_DataSource_Order_get)**  
    Creates an instance of the DataSource.Order class.

### get(tableName, columnName, direction)

Creates an instance of the [DataSource.Order](#apex_class_DataSource_Order "Contains details about how to sort the rows in the result set. Equivalent to an ORDER BY statement in a SOQL query.") class.

#### Signature

public static DataSource.Order get(String tableName, String columnName, DataSource.OrderDirection direction)

#### Parameters

- **tableName**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    Name of the table whose column values are used to sort the rows in the result set.
- **columnName**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    Name of the column whose values are used to sort the rows in the result set.
- **direction**:
    
    Type: [DataSource.OrderDirection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_DataSource_OrderDirection.htm "Specifies the direction for sorting rows based on column values.")
    
    Direction
    
    for sorting rows based on column values.

#### Return Value

Type: [DataSource.Order](#apex_class_DataSource_Order "Contains details about how to sort the rows in the result set. Equivalent to an ORDER BY statement in a SOQL query.")