> Documentation index: https://firebase.google.com/docs/reference/swift/firebasefirestore/api/reference/Classes/llms.txt

# Rank

    public class Rank : WindowFunction, @unchecked Sendable

**\[Public Preview\]** Returns the rank of each document within its partition according to the
window's sort order. Documents with equal sort values receive the same rank, and the following
rank is skipped. The window must specify exactly one sort ordering.

Example usage:

    firestore.pipeline()
      .collection("sales")
      .addWindowFields(
        window: .partition(["product"]).sort(Field("salesPrice").descending()),
        fields: [
          Rank().as("topSalesRank")
        ]
      )

Warning

Window Functions SDK features are in preview until the backend feature
launches. Look for the launch announcement at:
<https://docs.cloud.google.com/firestore/docs/release-notes>
- `


  ### [init()](https://firebase.google.com/docs/reference/swift/firebasefirestore/api/reference/Classes/Rank.md.txt#/s:17FirebaseFirestore4RankC4init_F)


  ` Initializes a new `Rank` window function.

  #### Declaration

  Swift

      public init()