LogoLogo
About
Tables: v2
  • Home
  • Guides
  • BDK
  • REST API
  • Release Notes
Tables: v2
  • Getting Started
    • Tables Overview
  • Table Creation
    • Create a Table
    • Create a Sample Table
    • Create a Pivot Table
    • Create an Integer Table
    • Create a Table from JSON
    • Create a Table from the Rows
    • Create a Combined Table
    • Create a Merged Table
    • Get a Table from a File
  • Rows
    • Get Row(s)
    • Get Row Count
    • Get Row Number
    • Get Value from Row
    • Group Rows
    • Insert a Row
    • Insert an Empty Row
    • Remove Duplicate Rows
    • Set a Row to JSON
  • Columns
    • Get a Column
    • Get a Column's Values
    • Get a Column Number
    • Get Column Count
    • Get Column Stats
    • Get Column Names
    • Change a Column's Data Type
    • Delete Columns
    • Insert a Column
    • Move a Column
    • Rename a Column
    • Rename Columns
    • Round a Column's Values
    • Update a Column
  • Cells
    • Set a Cell in a Table
  • Conversions
    • Convert CSV to a Table
    • Convert a Table to CSV
    • Convert a Table to Excel
  • Manipulations
    • Clear a Table
    • Combine Tables
    • Copy a Table
    • Extract a Subtable
    • Group a Table
    • Query a Table
    • Sort a Table
    • Split a Table
    • Join Subtables
    • Replace a Value
    • Replace a Value in a Column
    • Transpose a Table
Powered by GitBook
On this page
  • Overview
  • Input Concepts
  • Output Concepts
  • Examples

Was this helpful?

Export as PDF
  1. Manipulations

Sort a Table

Sorts a table by one or more columns with optional ascending/descending order.

Overview

This procedure sorts a table by one or more columns. The sort order (ascending or descending) can be specified. Optionally, you can specify a list of sort orders for multiple columns.

This is useful in a variety of situations—for example, you can sorting a score or sales column, arrange items alphabetically by name or category, or sort by date to show the most recent entries first.

Input Concepts

Concept
Type
Description
Default
Required

table

table

The table to be sorted.

No default

Yes

column

text

The column(s) by which the table should be sorted. Can be a single column name or comma-separated list.

No default

Yes

order

text

Optional sort order for single column. Format: ascending / descending column_name

No default

No

orders

text

Optional list of sort orders for multiple columns. Format: ascending / descending column_name for each column.

No default

No

Output Concepts

Concept
Description

table

The sorted table.

Examples

For these examples, say we create a table using the following command:

create a table where
    the column names are "name", "age" and "address"

1. Sort with Default Ascending Order

In this example, no order is specified, so the default sorting order is ascending.

sort the table by "age"

2. Sort with Default Descending Order

In this example, the "age" column is sorted in descending order.

sort the table by "age" where
    the order is "descending age"

3. Sort Multiple Columns

In this example, both the "city" and "age" columns are sorted in different orders.

sort the table by "city, age" where
    the orders are "descending city", "ascending age"

Last updated 1 month ago

Was this helpful?