# Change Result Sorting (Display Order)

By default, the IDOL Content component lists query results in order of relevance. To weight and rank the documents it returns by statistical relevance, Content uses complex algorithms that use a combination of information theory and Bayesian methods. It makes use of information theoretic values calculated dynamically for all concepts on indexing, which allows it to evaluate relevance both as a percentage, and in the case of agents, as absolute values.

In practice, the relevance acts as a measure of the conceptual overlap between the query text and the text within a document. You can affect the relevance in several ways. You can apply extra weight to certain fields by associating a weighting factor with them at indexing time. For example, you can give extra weight when query terms appear in the document title as opposed to the body of the text.

You can change the order in which Content returns query results by adding the `Sort` parameter to your `Query`, `Suggest`, `SuggestOnText`, `GetTagValues`, or `GetQueryTagValues` action.

## Sort Options for Query, Suggest, and SuggestOnText

The following table lists the `Sort` options that are available for the `Query`, `Suggest`, and `SuggestOnText` actions.

`Off` | Displays results unsorted.
`AutnRank` | Displays results in order of the value in their `AutnRankType` field. This method lists the document with the highest `AutnRankType` field value first.
`Cluster` | Displays results in order of cluster (in decreasing cluster ID order), if you also add `Cluster=True` to the action. If you specify `Cluster` as one of multiple sorting options, it automatically takes precedence over the other sorting methods, even if you did not put it in first place.
`Database` | Displays results in order of database number (in increasing order). Define the database numbers in the IDOL Content component configuration file.
`Date` | Displays results in order of their date (the date contained in the `DateType` fields). This method lists the most recent document first. If several documents have the same date, their display order is determined by their `autn:docid` (document ID) number (the highest `autn:docid` is listed first).
`Distcartesian` | Displays results according to their distance from a specified point using Cartesian coordinates (X/Y). The option has this format:
    sort=Distcartesian{coordX,coordY}:POSITION
where: `coordX` is the specified x coordinate. `coordY` is the specified y coordinate. `POSITION` is either: a single document field that contains the position information in Well-known text format POINT definitions. This field must be a unified `GeospatialType` field. two fields, in the format `X:Y`, where `X` is the document field that contains the X coordinates, and `Y` is the document field that contains the Y coordinates. These fields must be either `GeospatialType` or `NumericType` fields. You must specify the fields in the order X:Y. You must specify two fields in the order `X:Y`.
`Distspherical` | Displays results according to their distance from a specified point using spherical coordinates (latitude and longitude). The option has this format:
    sort=Distspherical{lat,long}:LOCATION
where: `lat` is the specified latitude. Specify latitude positions south of the equator as negative. `long` is the specified longitude. Specify longitude positions west of the Greenwich Meridian as negative. `LOCATION` is either: a single document field that contains the location information in Well-known text format POINT definitions. This field must be a unified `GeospatialType` field. two fields, in the format `Latfield:Longfield`, where `Latfield` is the document field that contains the latitude, and `Longfield` is the document field that contains the longitude. These fields must be either `GeospatialType` or `NumericType` fields. You must specify the fields in the order `latitude:longitude`.
`DocIDDecreasing` | Displays results in order of their `autn:docid` (document ID) number. This method lists the document with the highest `autn:docid` first.
`DocIDIncreasing` | Displays results in order of their `autn:docid` (document ID) number. This method lists the document with the lowest `autn:docid` first.
`fieldName:sortMethod` | Displays results in the order specified by `sortMethod`, based on the value of the Content field `fieldName`. This option is optimized if `fieldName` is a `MatchType` field. The following sort methods are available: `alphabetical`. Determines the display order of results by the string contained in `fieldName`. This method lists results in alphabetical order. (Sorting is faster if `fieldName` is `MatchType`.) `decreasing`. Determines the display order of results by the number or string contained in `fieldName`. This method lists the result with the highest number or the result that is last in alphabetical order first. For `NumericType` fields, this method is equivalent to `numberdecreasing`. For `MatchType` fields, this method is equivalent to `reversealphabetical`. `increasing`. Determines the display order of results by the number or string contained in `fieldName`. This method lists the result with the lowest number or the result that is first in alphabetical order first. For `NumericType` fields, this method is equivalent to `numberincreasing`. For `MatchType` fields, this method is equivalent to `alphabetical`. `numberdecreasing`. Determines the display order of results by the number contained in `fieldName`. This method lists the result with the highest number first. (Sorting is faster if `fieldName` is `NumericType`.) `numberincreasing`. Determines the display order of results by the number contained in `fieldName`. This method lists the result with the lowest number first. (Sorting is faster if `fieldName` is `NumericType`.) `reversealphabetical`. Determines the display order of results by the string contained in `fieldName`. This method lists results in reverse alphabetical order. (Sorting is faster if `fieldName` is `MatchType`.)
`Random` | Displays results in random order.
`Relevance` | Displays results in order of their relevance. This method lists the document with the highest relevance first. If documents have the same relevance, this method determines their display order by their `autn:docid` (document ID) number, and lists the highest `autn:docid` first.
`ReverseDate` | Displays results in order of their date (the date contained in the `DateType` fields). It lists the oldest document first. If several documents have the same date, this method determines their display order by their `autn:docid` (document ID) number, and lists the highest `autn:docid` first.

If you want to sort results by several criteria, you can specify them as follows:

    sortOption1+sortOption2+...

Example 1:

    http://MyHost:20000/action=Query&Text=presidential elections&Sort=Date

In this example, Content displays results in order of the document date.

Example 2:

    http://MyHost:20000/action=Query&Text=presidential elections&Sort=DRETITLE:reversealphabetical

In this example, Content displays results in reverse alphabetical order by their `DRETITLE`.

Example 3:

    http://MyHost:20000/action=Query&Text=presidential elections&Sort=Relevance+DRETITLE:alphabetical+Date

In this example, results order by `Relevance`, then by their `DRETITLE`, and then by their `Date`.

## Sort for GetTagValues and GetQueryTagValues

The following table lists the `Sort` options that are available for the `GetTagValues` and `GetQueryTagValues` actions.

`Off` | Displays results unsorted.
`Alphabetical` | Determines the display order of results by the string contained in the query field. Displays results in alphabetical order.
`Date` | Determines the display order of results by the date contained in the query field. This method lists the most recent result first.
`NumberDecreasing` | Determines the display order of results by the number contained in the query field. This method lists the result with the highest number first.
`NumberIncreasing` | Determines the display order of results by the number contained in the query field. This method lists the result with the lowest number first.
`ReverseAlphabetical` | Determines the display order of results by the string contained in the query field. This method displays results in reverse alphabetical order.
`ReverseDate` | Determines the display order of results by the date contained in the query field. This method lists the oldest result first.

For the `GetQueryTagValues` action, these `Sort` options are also available:

`DocumentCount` | If you set the `DocumentCount` action parameter to `True`, you can use this option to display results in order of their document count (in decreasing order).
`ReverseDocumentCount` | If you set the `DocumentCount` action parameter to `True`, you can use this option to display results in the reverse order of their document count (in increasing order).

For example:

    http://MyHost:20000/action=GetQueryTagValues&FieldName=GRAPE,COUNTRY &Text=A smooth red wine that complements game&Sort=Alphabetical

In this example, Content displays results in alphabetical order.

TIP: The `GetQueryTagValues` action also has a `QuerySort` parameter, which determines how it sorts the results of the associated query when it retrieves values.

For example, if you set `MaxResults` in `GetQueryTagValues`, the action retrieves parametric values from the first `N` results, according to the result sorting method. You can use `QuerySort` to specify how to sort these results. The options for `QuerySort` are the same as for the `Query` action `Sort` parameter (see Sort Options for Query, Suggest, and SuggestOnText).

_FT_HTML5_bannerTitle.htm