Skip to main content Skip to footer

Array Sort by List Documentation

Version: 1.0.0
Retrieved: 2025-10-09 15:15:13


Array Sort by List

Sorts an array of objects using the value of objects Key Property and according to the sort order specified in Key Values.

Objects in the incoming array are ignored and excluded from the result in these cases:

  • Object has no Key Property.
  • Object has Key Property that is not a string.
  • Objects has Key Property with value that does not correspond to a value in Key Values

Possible errors

If the value of Source Property is not an array of objects, the module will warn and will not send a message to modules connected to it.

Settings

Name Requirements Purpose Default
Source property String 1-64 in length The property containing the object to convert data
Target property String 1-64 in length The property to write the array to data
Key property String 1-64 in length The property with the key to use for sorting key
Key Values List of strings Specifies the sort order of the objects  

Example

# Settings:
Source Property = data
Target Property = data
Key Property = key
Key Values = ["sensor_1", "sensor_4", "sensor_3"]

# Incoming messages:
{
  "data": [
    {
        "key": "sensor_1",
        "temp": 31.1,
    },
    {
        "key": "sensor_2",
        "temp": 32.2,
    },
    {
        "key": "sensor_3",
        "temp": 33.3,
    },
    {
        "key": "sensor_4",
        "temp": 34.4,
    },
    {
        "key": "sensor_4",
        "temp": 34.5,
    },
    {
        "key": 5,
        "temp": 35.5,
    },
    {
        "temp": 36.6,
    }
  ]
}

# Outgoing message:
{
  "data": [
    {
        "key": "sensor_1",
        "temp": 31.1,
    },
    {
        "key": "sensor_4",
        "temp": 32.2,
    },
    {
        "key": "sensor_4",
        "temp": 34.5,
    },
    {
        "key": "sensor_3",
        "temp": 33.3,
    }
  ]
}

NOTE:

  • Object with key "sensor_2" is ignored since it is missing from key values.
  • Object with key 5 is ignored since key is not a string.
  • Object without key property is ignored.
  • The order between the objects with the same key("sensor_4") is kept from input.