Ordering

@Beta
public final classOrdering


Represents an ordering criterion for sorting documents in a Firestore pipeline.

You createOrdering instances using theascending anddescending helper methods.

Summary

Nested types

public static classOrdering.Companion
public enumOrdering.Direction extendsEnum

Public methods

static final @NonNullOrdering

Create anOrdering that sorts documents in ascending order based on value ofexpr.

static final @NonNullOrdering

Creates anOrdering that sorts documents in ascending order based on field.

static final @NonNullOrdering

Create anOrdering that sorts documents in descending order based on value ofexpr.

static final @NonNullOrdering

Creates anOrdering that sorts documents in descending order based on field.

boolean
equals(Object other)
int

Public fields

dir

public final @NonNullOrdering.Direction dir

expr

public final @NonNullExpression expr

Public methods

ascending

public static final @NonNullOrdering ascending(@NonNullExpression expr)

Create anOrdering that sorts documents in ascending order based on value ofexpr.

Parameters
@NonNullExpression expr

The order is based on the evaluation of theExpression.

Returns
@NonNullOrdering

A newOrdering object with ascending sort byexpr.

ascending

public static final @NonNullOrdering ascending(@NonNullString fieldName)

Creates anOrdering that sorts documents in ascending order based on field.

Parameters
@NonNullString fieldName

The name of field to sort documents.

Returns
@NonNullOrdering

A newOrdering object with ascending sort by field.

descending

public static final @NonNullOrdering descending(@NonNullExpression expr)

Create anOrdering that sorts documents in descending order based on value ofexpr.

Parameters
@NonNullExpression expr

The order is based on the evaluation of theExpression.

Returns
@NonNullOrdering

A newOrdering object with descending sort byexpr.

descending

public static final @NonNullOrdering descending(@NonNullString fieldName)

Creates anOrdering that sorts documents in descending order based on field.

Parameters
@NonNullString fieldName

The name of field to sort documents.

Returns
@NonNullOrdering

A newOrdering object with descending sort by field.

equals

public boolean equals(Object other)

hashCode

public int hashCode()

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-15 UTC.