---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, PMD Scripting, Scripts]
nav: wcp_docs
parent_url: /wcp_docs/
title: sort (list, key, ascendingOrder)
layout: subsection
---

## <a id="section_m3p_myb_5db"></a>Description

Sorts a given list on the specified attribute key. The `list:sort` function sorts data of simple type, such as integer, double, and string.

## <a id="section_dz5_pwg_5db"></a>Namespace Function Syntax

```
list:sort(list, key, ascendingOrder)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>list</td><td>A map list of Objects to sort.</td></tr><tr><td>key</td><td>The name of the attribute as the sort key.</td></tr><tr><td>ascendingOrder</td><td><ul><li><code>true</code> - Sorts the list in ascending order.
</li><li><code>false</code> - Sorts the list in descending order.
</li></ul></td></tr></tbody></table><br/>

## <a id="section_tkc_dyb_5db"></a>Example

Assume that <i>countries.items</i> contains this list of data from an endpoint:

```
[
  {
    "defaultCurrency": "AED",
    "name": "United Arab Emirates",
    "ISO_3166_1_Alpha_3_Code": "ARE"
  },
  {
    "defaultCurrency": "GBP",
    "name": "United Kingdom",
    "ISO_3166_1_Alpha_3_Code": "GBR"
  },
  {
    "defaultCurrency": "USD",
    "name": "United States Minor Outlying Islands",
    "ISO_3166_1_Alpha_3_Code": "UMI"
  },
  {
    "defaultCurrency": "USD",
    "name": "United States of America",
    "ISO_3166_1_Alpha_3_Code": "USA"
  }
]
```

`<% list:sort(countries.items, 'name', false ) %>`

Returns:

```
[
  {
    "defaultCurrency": "USD",
    "name": "United States of America",
    "ISO_3166_1_Alpha_3_Code": "USA"
  },
  {
    "defaultCurrency": "USD",
    "name": "United States Minor Outlying Islands",
    "ISO_3166_1_Alpha_3_Code": "UMI"
  },
  {
    "defaultCurrency": "GBP",
    "name": "United Kingdom",
    "ISO_3166_1_Alpha_3_Code": "GBR"
  },
  {
    "defaultCurrency": "AED",
    "name": "United Arab Emirates",
    "ISO_3166_1_Alpha_3_Code": "ARE"
  }
]
```

