> For the complete documentation index, see [llms.txt](https://docs.openbrim.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openbrim.org/developers/paramml-developer-guide/functions/custom-function/sort-list-or-sort-list-xindex-or-xparameter.md).

# sort (List) or sort (List, x\[index] or x.parameter)

**sort (List) → List**

It creates a new list by sorting the elements of the given list in ascending order. **sort (List,x\[index]) → List of list**

It creates a new list by sorting the elements based on given index for the list of lists. **sort (List,x\[index]) → List of objects**

It creates a new list of objects by sorting the objects based on given parameter.

**Example:**

```xml
<O N="sortObject1" T="Project" Category="Functions" TransAlignRule="1">
    <!-- created by ParamML Examples on 8/24/2023 -->
    <P N="List" V="[5,3,10,7,1]" />
    <P N="sorted_List" V="sort(List)" />
    <P N="List2" V="[[1,2],[10,5],[4,8],[2,1]]" />
    <P N="sorted_List2" V="sort(List2,x[0])" />
    <O N="Object1" T="Group">
        <P N="a" V="7" />
    </O>
    <O N="Object2" T="Group">
        <P N="a" V="15" />
    </O>
    <O N="Object3" T="Group">
        <P N="a" V="3" />
    </O>
    <O N="Object4" T="Group">
        <P N="a" V="11" />
    </O>
    <P N="List3" V="[Object1,Object2,Object3,Object4]" />
    <P N="Sorted_list3" V="sort(List3,x.a)" />
</O>
```

![](https://openbrim.atlassian.net/wiki/download/attachments/2167603313/image-20230824-085903.png?api=v2) As illustrated above, sorted\_List sorts the numerical elements while sorted\_List2 sorts a list of list based on the first element on each sublist and sorted\_List3 sorts a list of objects based on the value of “a” parameter. To view this example in the library, see (<https://openbrim.org/app/?incubator=1&author=ParamML_Examples_OpenBrIM+Platform&obj=objidc1cp27ykn9n8ejzdaiwjfl> )


---

# 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.openbrim.org/developers/paramml-developer-guide/functions/custom-function/sort-list-or-sort-list-xindex-or-xparameter.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.
