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:

<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>

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=objidc1cp27ykn9n8ejzdaiwjflarrow-up-right )

Last updated