Sort Object Array

Provides the ability to sort an array of multi-level/complex objects by the definition provided.

Version 1

HTTP Request
POST /ado/v1/SortObjectArray

Header

ParameterDescription
Ocp-Apim-Subscription-KeyThe subscription key you received when you purchased a plan.

Request Body

Mandatory

ParameterTypeDescription
dataobject[]Array of complex, multi-level objects.
sortOrderobjectThis should be an object with each property name being a path (separated by full stops/periods in a hierarchical manner) which indicates the property to sort on.

The order of the properties will determine the order that data is sorted in.

Examples

Simple

This example demonstrates a complex array of multi-level objects sorted, firstly, by property field2.field2_1 in a descending order with a second level of sorting occurring on property field2.field2_2 in an ascending order.

Request

{
    "sortOrder": {
        "field2.field2_1": "DESC",
        "field2.field2_2": "ASC"
    },
    "data": [
        {
            "field1": 744,
            "field2": {
                "field2_1": 528,
                "field2_2": 429
            },
            "field3": 114
        },
        {
            "field1": 987,
            "field2": {
                "field2_1": 765,
                "field2_2": 562
            },
            "field3": 265
        },
        {
            "field1": 235,
            "field2": {
                "field2_1": 528,
                "field2_2": 246
            },
            "field3": 946
        }        
    ]
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "field1": 987,
        "field2": {
            "field2_1": 765,
            "field2_2": 562
        },
        "field3": 265
    },
    {
        "field1": 235,
        "field2": {
            "field2_1": 528,
            "field2_2": 246
        },
        "field3": 946
    },
    {
        "field1": 744,
        "field2": {
            "field2_1": 528,
            "field2_2": 429
        },
        "field3": 114
    }
]
Code language: JSON / JSON with Comments (json)