Class | Ferret::Search::Sort
In: | ext/r_search.c
Parent: | Object

## Summary

A Sort object is used to combine and apply a list of SortFields. The SortFields are applied in the order they are added to the SortObject.

## Example

Here is how you would create a Sort object that sorts first by rating and then by title;

      sf_rating = SortField.new(:rating, :type => :float, :reverse => true)
      sf_title = SortField.new(:title, :type => :string)
      sort = Sort.new([sf_rating, sf_title])

Remember that the :type parameter for SortField is set to :auto be default be I strongly recommend you specify a :type value.

### Methods

fields new to_s

### Constants

RELEVANCE | = | frt_sort_init(0, NULL, frt_sort_alloc(cSort))
INDEX_ORDER | = | frt_sort_init(1, &oSORT_FIELD_DOC, frt_sort_alloc(cSort))

### Public Class methods

Sort.new(sort_fields = [SortField::SCORE, SortField::DOC_ID], reverse = false) → Sort

Create a new Sort object. If `reverse` is true, all sort_fields will be reversed so if any of them are already reversed the will be turned back to their natural order again. By default

### Public Instance methods

sort.fields → Array

Returns an array of the SortFields held by the Sort object.

sort.to_s → string

Returns a human readable string representing the sort object.

[Validate]