Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use SortField to sort my data numerically in Flex/ActionScript?
    text
    copied!<p>From the documentation:</p> <p><strong>SortField () constructor</strong></p> <pre><code>public function SortField(name:String = null, caseInsensitive:Boolean = false, descending:Boolean = false, numeric:Object = null) </code></pre> <p>I'm confused on the last part - <code>numeric:Object = null</code>.</p> <p>Here is my function:</p> <pre><code>private function createXMLDataProvider():XMLListCollection{ var sort:Sort = new Sort(); sort.fields = [new SortField("@sortorder",true,false,true), new SortField("@label")]; var searchTypesCollection:XMLListCollection = new XMLListCollection(getAssociations(_appData.searchTypes, "category", searchType)); searchTypesCollection.sort = sort; searchTypesCollection.refresh(); return searchTypesCollection; } </code></pre> <p>On this line:</p> <pre><code>sort.fields = [new SortField("@sortorder",true,false,true), new SortField("@label")]; </code></pre> <p>The first SortField is a number but is being compared like it is text. What should I be putting where it says true?</p> <p>Also from the documentation:</p> <p>Specifies that if the field being sorted contains numeric (number/int/uint) values, or string representations of numeric values, the comparator use a numeric comparison. If this property is false, fields with string representations of numbers are sorted using strings comparison, so 100 precedes 99, because "1" is a lower string value than "9". If this property is null, the first data item is introspected to see if it is a number or string and the sort proceeds based on that introspection.</p> <p>The default value is false.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload