Developer Guide: Specifying Sort Order

Most strategies allow you to control the order of the results they return. In this guide you'll learn how to apply ordering to result sets.

Supported sort options

The sorting options supported by each strategy vary, and are based upon the fields given for each result in the output.

Most strategies support the following fields that results can be sorted by:

  • engagement_ratio - a score which tells you how engaged your audience is with the result item, versus the selected comparison audience.
  • unique_authors - the number of unique audience members who have engaged with the result item.
  • interactions - the number of engagements that relate to the result item.

By default most strategies sort results by the engagement_ratio score, therefore results are returned in decreasing relevance to your analyzed audience.

Some strategies support additional sorting options. You'll find the sort options detailed within the documentation for the strategy.

Using the sort_by parameter

You specify the sort order of results using the sort_by parameter.

For example, the following parameters will run the top_urls strategy, returning results in order of decreasing audience size:

# POST /pylon/linkedin/task
{
  "type": "strategy",
  "subscription_id": "cd99abbc812f646c77bfd8ddf767a134f0b91e84",
  "name": "Top urls for cloud",
  "parameters": {
    "strategy": "top_urls",
    "version": 1,
    "parameters": {
      "sort_by": "unique_authors",
      "keywords": {
        "any": ["cloud", "azure", "aws", "google cloud", "vmware"]
      },
      "comparison_audience": "global"
    }
  }
}

The sort_by parameter is optional. If you do not specify this parameter the strategy will apply a default sort as documented for the strategy.

Currently the API only supports one level of sorting. You cannot specify multiple fields to sort by.

Sorting results for groups analysis

For grouped analysis the sort order is applied to the results for each group independently. The same sorting options are available for grouped analysis as for analysis without grouping.