> For the complete documentation index, see [llms.txt](https://docs.rewst.help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rewst.help/documentation/automations/actions-in-rewst/transform-actions/sort-transform-action.md).

# Sort transform action

## Use case

You are listing users from Microsoft Graph and you would like to sort the result alphabetically based on their displayName attribute.

## Overview

Given an iterable, return a new sorted list from the items in the iterable.

## Parameters

<table><thead><tr><th width="217">Parameter</th><th width="417.3333333333333">Description</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>Attribute</td><td>When sorting a list of dictionaries, an attribute or key to sort by. Can use dot notation like "address.city".</td><td>false</td></tr><tr><td>Case Sensitive</td><td>When sorting strings, sort upper and lower case separately.</td><td>false</td></tr><tr><td>Input List or String</td><td>List or string to sort</td><td>true</td></tr><tr><td>Reverse Sort</td><td>If true, will sort in descending order instead of the ascending order.</td><td>false</td></tr></tbody></table>

{% hint style="info" %}
For nested field names, separate them by dots (e.g., `details.age`).
{% endhint %}

## Usage

<details>

<summary>Example 1: Sort Users By ID</summary>

Inputs:

*Attribute:* age

*Case Sensitive:* false

Input List or String:

```json
[
	{
		"id": 6,
		"name": "Dan6",
		"favorite_letter": "a"
	},
	{
		"id": 2,
		"name": "Dan2",
		"favorite_letter": "c"
	},
	{
		"id": 4,
		"name": "Dan4",
		"favorite_letter": "g"
	},
	{
		"id": 1,
		"name": "Dan1",
		"favorite_letter": "B"
	},
	{
		"id": 3,
		"name": "Dan3",
		"favorite_letter": "z"
	},
	{
		"id": 5,
		"name": "Dan5",
		"favorite_letter": "A"
	}
]
```

*Reverse Sort:* false

</details>

<details>

<summary>Example 2: Sort A List of Numbers</summary>

Inputs:

*Attribute:* age

*Case Sensitive:* false

Input List or String:

```json
[83, 42, 36, 30, 15, 54, 68, 30, 29]
```

*Reverse Sort:* false

</details>

## Results output

Results of example 1:

```json
[
  {
    "id": 1,
    "name": "Dan1",
    "favorite_letter": "B"
  },
  {
    "id": 2,
    "name": "Dan2",
    "favorite_letter": "c"
  },
  {
    "id": 3,
    "name": "Dan3",
    "favorite_letter": "z"
  },
  {
    "id": 4,
    "name": "Dan4",
    "favorite_letter": "g"
  },
  {
    "id": 5,
    "name": "Dan5",
    "favorite_letter": "A"
  },
  {
    "id": 6,
    "name": "Dan6",
    "favorite_letter": "a"
  }
]
```

Results of example 2:

```json
[
  15,
  29,
  30,
  30,
  36,
  42,
  54,
  68,
  83
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rewst.help/documentation/automations/actions-in-rewst/transform-actions/sort-transform-action.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
