Trying to order the array objects correctly after appending a new object

Hi all,

I am currently trying to append a new json object to an array, and then sort the array correctly. This is my current query for appending the object to the bottom of the array, which works fine. What would need to be added in order to order the objects by a certain field AFTER appending the new object?

@Query("MERGE INTO #{#n1ql.bucket} AS d USING [1] AS o ON KEY $1 " +
        "WHEN MATCHED THEN UPDATE SET d.schedule = ARRAY_SORT(ARRAY_APPEND(d.schedule, $2)) " +
        "WHEN NOT MATCHED THEN INSERT $3")