sort

Sorting rows can make subsequent computations easier and more efficient.

Use the"sort" directive to order rows of data by values in selected columns. Like other transformative directives, the "from" directive is required to work.

📘

The "sort" directive is a transformative directive.

The "sort" directive requires a declared "from" directive to be present in the same comment.

For instance, to sort the "Customer" worksheet rows by "Last name" descending with ties broken by "First name" ascending place the following directive in a comment in the "OrderedByLastName" worksheet.

pebblestream:from(Customer)
pebblestream:sort("Last name":desc, "First name":asc, ...)

The "sort" directive cannot be used with the "group" directive.

❗️

Important!

The "sort" directive cannot be combined with the "group" directive

Example 1

Consider the "Accounts" worksheet

ID

Balance

5

44

1

40

8

848

2

12

Using the following directive declaration in the "Sorted" worksheet

pebblestream:from(Accounts)
pebblestream:sort("ID")

results in the following:

ID

Balance

1

40

3

12

5

44

8

848

Example 2

Consider sorting a Transactions worksheet

First

Last

Date

John

Jones

9/2/2020

Adam

Jones

1/1/2000

Cathy

Albertson

5/7/1990

John

Jones

5/4/2013

using the directive declaration below

pebblestream:from(Transactions)
pebblestream:sort("Last", "First", "Date":desc)

to obtain the SortedTransactions worksheet:

First

Last

Date

Cathy

Albertson

5/7/1990

Adam

Jones

1/1/2000

John

Jones

9/2/2020

John

Jones

5/4/2013


Did this page help you?