# SearchSortBuilder

## AV. SearchSortBuilder

#### new SearchSortBuilder()

Source:
  - search.js, line 16
Since:
  - 0.5.1

A builder to generate sort string for app searching.For example:

##### Example

    var builder = new AV.SearchSortBuilder();
      builder.ascending('key1').descending('key2','max');
      var query = new AV.SearchQuery('Player');
      query.sortBy(builder);
      query.find().then();

### Methods

#### ascending(key, mode, missing) → {AV.SearchSortBuilder}

Source:
  - search.js, line 44

Sorts the results in ascending order by the given key and options.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to order by.
`mode` | String | The sort mode, default is 'avg', you can choose 'max' or 'min' too.
`missing` | String | The missing key behaviour, default is 'last', you can choose 'first' too.

##### Returns:

Returns the builder, so you can chain this call.

Type
  AV.SearchSortBuilder

#### build() → {String}

Source:
  - search.js, line 93

Build a sort string by configuration.

##### Returns:

the sort string.

Type
  String

#### descending(key, mode, missing) → {AV.SearchSortBuilder}

Source:
  - search.js, line 58

Sorts the results in descending order by the given key and options.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to order by.
`mode` | String | The sort mode, default is 'avg', you can choose 'max' or 'min' too.
`missing` | String | The missing key behaviour, default is 'last', you can choose 'first' too.

##### Returns:

Returns the builder, so you can chain this call.

Type
  AV.SearchSortBuilder

#### whereNear(key, point, options) → {AV.SearchSortBuilder}

Source:
  - search.js, line 70

Add a proximity based constraint for finding objects with key point values near the point given.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key that the AV.GeoPoint is stored in.
`point` | AV.GeoPoint | The reference AV.GeoPoint that is used.
`options` | Object | The other options such as mode,order, unit etc.

##### Returns:

Returns the builder, so you can chain this call.

Type
  AV.SearchSortBuilder