Sort Pattern

The Sort pattern provides sorting affordances. It often complements List and Tree patterns but can also be used to sort any resource with sortable element aspects. The Sort pattern has a Sort Info resource that describes the sorting configuration. Clients can change the sorting configuration with the Sorter resource. The elements in the resource should share the sortable properties for the Sorted resource to make sense to the client.

The client changes sort configuration by POSTing a new configuration form to the Sorter resource. Sorter returns the updated Sorted resource URL in it’s Location response header.

Sorted Resource

Profile: <>

The Sorted resource can present any profile. The profile choice does not effect filtering options.



Points to a Sort Info resource that describes the configuration of the Sorted resource’s element order.

Sort Info Resource

Profile: <>

The Sort Info resource describes the ordering configuration used in the Sorted resource. This configuration consists of an array of sorting declarations, which Sort Info’s representation assigns to a top-level sort-order element.

A sorting declaration in the sort-order array has these properties:

Property Purpose
property The property being sorted by.
direction Either ascend or descend.

Each additional sorting declaration sub-sorts the elements by that declaration. Consider this sort order array:

  "sort-order": [
    { "property": "age", "direction": "descend" }, 
    { "property": "last-name", "direction": "ascend" }

The elements are sorted first by age (oldest first), and inside each age group, the elements are sorted by last-name in ascending order (alphabetical).

The XML representation looks like this:

  <sort-by property="age" direction="descend"/> 
  <sort-by property="last-name" direction="ascend"/> 



Points to a Sorter resource that can configure the element order of the Sorted resource.

Sorter Resource

Profile: <>

The Sorter resource changes the Sorted resource’s sorting configuration. It is a Form resource that starts with the current configuration in its schema representation, or its template object if the Form resource does not use a schema. If only a subset of the properties is sortable, then the Sorter resource should present a schema to help the client submit a successful sorting change.

The Form creates a sorting declaration array. This array has objects with these properties:

Property Purpose
property The property being sorted by.
direction Either ascend or descend.



Points to the Sorted resource that this Sorter resource configures.

Copyright © 2019 Matt Bishop
Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.