View Source Resourceful.Collection.Sort (Resourceful v0.1.5)

Provides a common interface for sorting collections. See call/2 for use and examples.

This module is intended to dispatch arguments to the appropriate Sort module for the underlying data source.

Link to this section Summary

Functions

Returns a data source that is sorted in accordance with sorters.

Link to this section Types

@type coercible() :: t() | String.t()
@type t() :: {:asc | :desc, Resourceful.Collection.queryable()}

Link to this section Functions

Link to this function

call(data_source, sorters)

View Source
@spec call(any(), coercible() | [coercible()]) :: any()

Returns a data source that is sorted in accordance with sorters.

If data_source is not an actual list of resources (e.g. an Ecto Queryable) underlying modules should not return a list of resources, but rather a sorted version of data_source.

args

Args

  • data_source: See Resourceful.Collection module overview.
  • sorters: A list or comma separated string of sort parameters. Sort parameters should be the string name of a field preceded by, optionally, a + for ascending order (the default) or a - for descending order or. Examples of sorters:
    • "name,-age"
    • ["+name", "-age"]