Class Sort

java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Sort

public class Sort extends Stage
Sorts all input documents and returns them to the pipeline in sorted order.
  • Method Details

    • sort

      public static Sort sort()
      Creates a sort stage.
      Returns:
      the new stage
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $sort
    • ascending

      public Sort ascending(String field, String... additional)
      Adds an ascending sort definition on the field.
      Parameters:
      field - the sort field
      additional - any additional fields to sort on
      Returns:
      this
    • descending

      public Sort descending(String field, String... additional)
      Adds a descending sort definition on the field.
      Parameters:
      field - the sort field
      additional - any additional fields to sort on
      Returns:
      this
    • meta

      public Sort meta(String field)
      Adds a sort by the computed textScore metadata in descending order.
      Parameters:
      field - the sort field
      Returns:
      this