How to sort object by timestamp value

Hi there

I guess that’s an easy one for the pros. I would like to sort a list of object by date.timestamp value.

I have no problem as long as I use the createTime:

SORT_BY_KEY(data.Travels1, “createTime”, “asc”)

but I have troubles when trying to sort by date.timestampValue. I guess it is a matter of syntax.

I tried with all different sorts, for example:

SORT_BY_KEY(data.Travels1, “fields.date.timestampValue”, “asc”)

but with this for example I get the error message that “Value “fields.date.timestampValue” is not any of the following createTime, fields, …”

That’s the schema:

Hey,

In the formula editor the SORT_BY_KEY documentation states that it might not behave correctly with values that are not text or number types. So it might not work at all with datetime types. Also I believe the formula doesn’t allow for dot-notation, so it doesn’t support deeper nestings like objects within objects :confused:

Instead I would recommend the ORDER formula function, so ORDER(data.Travels1, item.fields.date.timestampValue, “asc”) :slight_smile:

2 Likes