blob: 2485a10d58ee580a0ea92fe046488811e78cc6e9 [file] [log] [blame]
{ "type": "class",
"qname": "spark.collections.Sort",
"baseClassname": "mx.collections.Sort"
,
"description": "Provides the sorting information required to establish a sort on an existing view (<code>ICollectionView</code> interface or class that implements the interface). After you assign a <code>Sort</code> instance to the view's <code>sort</code> property, you must call the view's <code>refresh()</code> method to apply the sort criteria. <p>Typically the sort is defined for collections of complex items, that is collections in which the sort is performed on one or more properties of the objects in the collection. The following example shows this use:</p> <pre><code>\\n var col:ICollectionView = new ArrayCollection();\\n // In the real world, the collection would have more than one item.\\n col.addItem({first:&quot;Anders&quot;, last:&quot;Dickerson&quot;});\\n \\n // Create the Sort instance.\\n var sort:ISort = new Sort();\\n \\n // Set the sort field; sort on the last name first, first name second.\\n var sortfieldLastName:ISortField = new SortField(&quot;last&quot;,true);\\n var sortfieldFirstName:ISortField = new SortField(&quot;first&quot;,true);\\n \\n // Set the locale style to &quot;en-US&quot; to cause the strings\\n // to be ordered according to the rules for English as used in the USA.\\n sortfieldLastName.setStyle(&quot;locale&quot;,&quot;en-US&quot;);\\n sortfieldFirstName.setStyle(&quot;locale&quot;,&quot;en-US&quot;);\\n sort.fields = [sortfieldLastName, sortfieldFirstName];\\n \\n // Assign the Sort object to the view.\\n col.sort = sort;\\n \\n // Apply the sort to the collection.\\n col.refresh();\\n </code></pre> <p>There are situations in which the collection contains simple items, like <code>String</code>, <code>Date</code>, <code>Boolean</code>, etc. In this case, apply the sort to the simple type directly. When constructing a sort for simple items, use a single sort field, and specify a <code>null</code> <code>name</code> (first) parameter in the SortField object constructor. For example: <pre><code>\\n import mx.collections.ArrayCollection;\\n import spark.collections.Sort;\\n import spark.collections.SortField;\\n \\n var col:ICollectionView = new ArrayCollection();\\n col.addItem(&quot;California&quot;);\\n col.addItem(&quot;Arizona&quot;);\\n var sort:Sort = new Sort();\\n \\n // There is only one sort field, so use a <code>null</code>\\n // first parameter.\\n var sortfield:SortField = new SortField(&quot;null&quot;,true);\\n \\n // Set the locale style to &quot;en-US&quot; to set the language for the sort.\\n sortfield.setStyle(&quot;locale&quot;,&quot;en-US&quot;);\\n sort.fields = [sortfield];\\n col.sort = sort;\\n col.refresh();\\n </code></pre> </p> <p>The Flex implementations of the <code>ICollectionView</code> interface retrieve all items from a remote location before executing a sort. If you use paging with a sorted list, apply the sort to the remote collection before you retrieve the data. </p> <p>The default comparison provided by the <code>SortField</code> class provides correct language-specific sorting for strings. The language is selected by setting the locale style on an instance of the class in one of the following ways: </p> <ul> <li> By using the class in an MXML declaration and inheriting the locale from the document that contains the declaration. </li> Example: <pre>\\n &lt;fx:Declarations&gt; <br>\\n &lt;s:SortField id=&quot;sf&quot; /&gt; <br>\\n &lt;/fx:Declarations&gt;\\n </pre> <li> By using an MXML declaration and specifying the locale value in the list of assignments. </li> Example: <pre>\\n &lt;fx:Declarations&gt; <br>\\n &lt;s:SortField id=&quot;sf_SimplifiedChinese&quot; locale=&quot;zh-Hans-CN&quot; /&gt; <br>\\n &lt;/fx:Declarations&gt;\\n </pre> <li> Calling the <code>setStyle</code> method, e.g. <code>sf.setStyle(&quot;locale&quot;, &quot;zh-Hans-CN&quot;)</code> </li> <li> Inheriting the style from a <code>UIComponent</code> by calling the UIComponent's <code>addStyleClient()</code> method. </li> </ul> Note: to prevent problems like <a href=&quot;https://issues.apache.org/jira/browse/FLEX-34853&quot;>FLEX-34853</a> it is recommended to use SortField instances as immutable objects (by not changing their state). <p>The <code>&lt;s:Sort&gt;</code> tag has the following attributes:</p> <pre>\\n &lt;s:Sort\\n <b>Properties</b>\\n compareFunction=&quot;<em>Internal compare function</em>&quot;\\n fields=&quot;null&quot;\\n unique=&quot;false | true&quot;\\n /&gt;\\n </pre> <p>In case items have inconsistent data types or items have complex data types, the use of the default built-in compare functions is not recommended. Inconsistent sorting results may occur in such cases. To avoid such problem, provide a custom compare function and/or make the item types consistent.</p>",
"tags": [
{ "tagName": "includeExample",
"values": ["examples/SortExample1.mxml", "examples/SortExample2.mxml"]},
{ "tagName": "see",
"values": ["mx.collections.ICollectionView", "spark.collections.SortField"]},
{ "tagName": "mxml",
"values": []},
{ "tagName": "playerversion",
"values": ["Flash 10.1", "AIR 2.5"]},
{ "tagName": "productversion",
"values": ["Flex 4.5"]},
{ "tagName": "langversion",
"values": ["3.0"]} ],
"members": [
{ "type": "accessor",
"access": "read-write",
"return": "Object",
"qname": "styleName",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {}},
{ "type": "field",
"qname": "ANY_INDEX_MODE",
"return": "String",
"namespace": "public",
"bindable": [],
"details": ["static"],
"deprecated": {},
"description": "When executing a find return the index any matching item.",
"tags": [
{ "tagName": "playerversion",
"values": ["Flash 10.1", "AIR 2.5"]},
{ "tagName": "productversion",
"values": ["Flex 4.5"]},
{ "tagName": "langversion",
"values": ["3.0"]} ]},
{ "type": "field",
"qname": "FIRST_INDEX_MODE",
"return": "String",
"namespace": "public",
"bindable": [],
"details": ["static"],
"deprecated": {},
"description": "When executing a find return the index for the first matching item.",
"tags": [
{ "tagName": "playerversion",
"values": ["Flash 10.1", "AIR 2.5"]},
{ "tagName": "productversion",
"values": ["Flex 4.5"]},
{ "tagName": "langversion",
"values": ["3.0"]} ]},
{ "type": "field",
"qname": "LAST_INDEX_MODE",
"return": "String",
"namespace": "public",
"bindable": [],
"details": ["static"],
"deprecated": {},
"description": "When executing a find return the index for the last matching item.",
"tags": [
{ "tagName": "playerversion",
"values": ["Flash 10.1", "AIR 2.5"]},
{ "tagName": "productversion",
"values": ["Flex 4.5"]},
{ "tagName": "langversion",
"values": ["3.0"]} ]},
{ "type": "method",
"qname": "spark.collections.Sort",
"namespace": "",
"bindable": [],
"details": [],
"deprecated": {},
"description": "Constructor. <p>Creates a new Sort with no fields set and no custom comparator.</p> specifies the fields to compare. objects in the collection to which this sort will be applied.",
"tags": [
{ "tagName": "param",
"values": ["fields An <code>Array</code> of <code>ISortField</code> objects that", "customCompareFunction Use a custom function to compare the", "unique Indicates if the sort should be unique."]},
{ "tagName": "playerversion",
"values": ["Flash 10.1", "AIR 2.5"]},
{ "tagName": "productversion",
"values": ["Flex 4.5"]},
{ "tagName": "langversion",
"values": ["3.0"]} ],
"return": "",
"params": [{ "name": "fields", "type": "Array"},
{ "name": "customCompareFunction", "type": "Function"},
{ "name": "unique", "type": "Boolean"}]}
,
{ "type": "method",
"qname": "createEmptySortField",
"namespace": "protected",
"bindable": [],
"details": ["override"],
"deprecated": {},
"return": "mx.collections.ISortField",
"params": []}
,
{ "type": "accessor",
"access": "read-only",
"return": "String",
"qname": "id",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {}},
{ "type": "accessor",
"access": "read-write",
"return": "mx.styles.IAdvancedStyleClient",
"qname": "styleParent",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {}},
{ "type": "method",
"qname": "stylesInitialized",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "void",
"params": []}
,
{ "type": "method",
"qname": "matchesCSSState",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "Boolean",
"params": [{ "name": "cssState", "type": "String"}]}
,
{ "type": "method",
"qname": "matchesCSSType",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "Boolean",
"params": [{ "name": "cssType", "type": "String"}]}
,
{ "type": "method",
"qname": "hasCSSState",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "Boolean",
"params": []}
,
{ "type": "accessor",
"access": "read-only",
"return": "String",
"qname": "className",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {}},
{ "type": "method",
"qname": "getStyle",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "*",
"params": [{ "name": "styleProp", "type": "String"}]}
,
{ "type": "accessor",
"access": "read-write",
"return": "mx.core.IFlexModuleFactory",
"qname": "moduleFactory",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {}},
{ "type": "method",
"qname": "initialized",
"namespace": "public",
"bindable": [],
"details": [],
"deprecated": {},
"return": "void",
"params": [{ "name": "document", "type": "Object"},
{ "name": "id", "type": "String"}]}
]
}