I can sort the values of the returned fields in the QueryBuilder Widget from the new Sample Viewer if the value is a string by calling a sortByAttribute function (see code below), and I can sort field if the value is numeric by calling the sortNumeric function (see below). My problem is that I need to be able to do both. I can do one or the other, and I will get a debugging error if, say I use the sortByAttribute function and load values for a number field, and vice versa if I use the sortNumeric function and load values from a string field. I haven't been able to make the script work by calling both functions using various attempts with 'if else'. Any help will be greatly appreciated.private function onFieldValuesRereivalsuccess(obj:Object):void{
mqbMessage = "Values has been retreived."
CursorManager.removeBusyCursor();
var fset:FeatureSet = obj as FeatureSet;
mqbMessage = "";
// mFldValues = fset.features;
mFldValues2 = fset.features;
var fldname:String = fieldsLst.selectedItem.Name
var contains:Boolean;
mFldValues = new Array();
for ( var i:Number = 0; i<mFldValues2.length; i++ )
{
contains = false;
for ( var j:Number = 0; j<mFldValues.length; j++ )
{
var item1:String = mFldValues2.attributes[fieldsLst.selectedItem.Name];
var item2:String = mFldValues.attributes[fieldsLst.selectedItem.Name];
if (item1 == item2) contains = true;
}
if (!contains)
{
mFldValues.push(mFldValues2);
}
}
mFldValues.sort(sortByAttribute);
}
//COMPARE FUNCTION
private function sortByAttribute(a:Object, b:Object):Object
{
var x:String = a.attributes[fieldsLst.selectedItem.Name].toLowerCase();
var y:String = b.attributes[fieldsLst.selectedItem.Name].toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
private function sortNumeric(a:Object, b:Object):int
{
var value1:Number = a.attributes[fieldsLst.selectedItem.Name];
var value2:Number = b.attributes[fieldsLst.selectedItem.Name];
return ((value1 < value2) ? -1 : ((value1 > value2) ? 1 : 0));
} Thanks,Jim FaronAustin Independent School DistrictAustin, TX