Converting aggregation stage to Java

I’m working on a small project to get used to working with MongoDB and Java but I’m having a little difficulty converting a working stage (as in, tested and getting the results I’m looking for) from the text format in MongoDB Compass to the Java equivalent using Bson objects created using the Aggregates builders.

Here is the text format from Compass:

{
    $set:
      {
        actorInfo: {
          $sortArray: {
            input: "$actorInfo",
            sortBy: {
              lastName: 1,
              firstName: 1
            }
          }
        }
      }
  }
{
  "title": "Avengers",
  "rating": "PG-13",
  "release_date": {
    "$date": "2012-05-04T06:00:00.000Z"
  },
  "actorInfo": [
    {
      "firstName": "Robert",
      "lastName": "Downey Jr"
    },
    {
      "firstName": "Chris",
      "lastName": "Evans"
    },
    {
      "firstName": "Chris",
      "lastName": "Hemsworth"
    },
    {
      "firstName": "Samuel",
      "lastName": "L Jackson"
    }
  ]
}

I am seeing that the Aggregates class has a set function but I’m having trouble finding any documentation online about how to use the Field objects.

I know I can export the text directly from Compass and it will build out a massive tree of “new Document(…)” but I am trying to figure out how to work with the Aggregates class and its methods.

Thank you

Sorry, didn’t think about adding this until I’d already posted. An example of what I’m trying to do would be the following:

Text:

{
    $lookup: {
      from: "actors",
      localField: "actors",
      foreignField: "_id",
      as: "actorInfo"
    }
  }

Java and BSON:

Bson lookup = Aggregates.lookup("actors", "actors", "_id", "actorInfo");