Ash.Query.sort
You're seeing just the function
sort
, go back to Ash.Query module for more information.
Specs
sort(t() | Ash.Resource.t(), Ash.Sort.t()) :: t()
Sort the results based on attributes, aggregates or calculations.
Calculations are supported if they are defined with expressions, which can be done one of two ways.
- with the shorthand
calculate :calc, :type, expr(a + b)
- By defining
expression/2
in a custom calculation module
See the guide on calculations for more.
Takes a list of fields to sort on, or a keyword list/mixed keyword list of fields and sort directions.
The default sort direction is :asc
.
Examples:
Ash.Query.sort(query, [:foo, :bar])
Ash.Query.sort(query, [:foo, bar: :desc])
Ash.Query.sort(query, [foo: :desc, bar: :asc])