Comfortable | Docs
  • Comfortable Documentation
  • Concepts
    • Content Repositories
    • Content Types
    • Documents
    • Assets
    • Content Tree
    • Collections
    • Webhooks
    • Team
    • Locales
  • APIs
    • RESTful API
      • Endpoints
      • API Reference
        • Sorting
        • Filters
        • Localisation
        • Fields
        • Includes
        • Search
      • Query Examples
        • Collections
        • Single Documents
        • Single Assets
        • Sorting
        • Filters
        • Includes
    • Image Manipulation
  • SDKs
    • JavaScript
      • Query Options
      • Query All Documents
      • Query a Collection
      • Query a Single Document
      • Query an Alias
      • Query an Asset
      • Example: Filters
      • Example: Sorting
    • Nuxt.js
    • PHP
      • Query All Documents
      • Query Single Document
      • Query Collection
      • Query an Alias
      • Query an Asset
      • Fulltext Search
      • Query by Fields
      • Query by Type
      • Query by Id
      • Query by Tags
  • Guides
    • Vue Blog Example
  • Legal
    • Legal Notice
    • Privacy Policy
Powered by GitBook
On this page
  • Sorted query results
  • Field Types
  • Examples
  1. APIs
  2. RESTful API
  3. API Reference

Sorting

PreviousAPI ReferenceNextFilters

Last updated 6 years ago

Apply sorting for list endpoints like and . Each sorting parameter refers to one field. It is possible to provide a single or multiple sorting parameters.

Possible values for the sorting parameter are:

Value

Function

ASC or 1

Returns the list ordered ascending

DESC or -1

Returns the list ordered descending

Lists are ordered descending by default.

Sorted query results

GET https://api.cmft.io/v1/<repoName>/<endpoint>?sorting[<fields|meta>.<fieldName>]=<direction>

Path Parameters

Name
Type
Description

repoName

string

The API identifier of the repository

endpoint

string

The endpoint you'd like to request

sorting

string

Provide the order direction ASC or DESC

Headers

Name
Type
Description

Authorization

string

Provide an API Key

// Response ordered ascending by title
"data": [
    {
      "fields": {
        "title": "Roses are red"
      },
      "meta": {
        "id": "314159265358979323",
        "contentType": "poem",
        "repository": "314159265358979323",
        "revision": 1,
        "tags": [],
        "createdAt": "2018-01-01T00:00:00.000Z",
        "updatedAt": "2018-01-01T00:00:00.000Z"
      }
    },
    {
      "fields": {
        "title": "Violets are blue"
      },
      "meta": {
        "id": "314159265358979323",
        "contentType": "poem",
        "repository": "314159265358979323",
        "revision": 1,
        "tags": [],
        "createdAt": "2018-01-01T00:00:00.000Z",
        "updatedAt": "2018-01-01T00:00:00.000Z"
      }
    }
]

Field Types

Sorting can be applied for the following field types:

  • Text

  • Richtext

  • Number

  • Date & Time

  • Boolean

  • Location

  • Select

  • Color

Examples

Find some examples on the query examples page:

Sorting
All Documents
Document Collections