, , , .
After suffering this for a while, I discovered one way to avoid the problems you were talking about.
Just use the ArrayCollection helper array to sort . In any case, your Sort instance seems temporary (you want to skip it), so why not use a temporary ArrayCollection?
This is what my code looked like:
var alphabeticSort:ISort = new Sort();
var sortfieldFirstName:ISortField = new SortField("firstName",true);
var sortfieldLastName:ISortField = new SortField("lastName",true);
alphabeticSort.fields = [sortfieldFirstName, sortfieldLastName];
var aux:ArrayCollection = new ArrayCollection();
while (myArrayCollection.length > 0) {
aux.addItem(myArrayCollection.removeItemAt(0));
}
var previousSort:ISort = aux.sort;
aux.sort = alphabeticSort;
aux.refresh();
aux.sort = previousSort;
var auxLength:int = aux.length;
while (auxLength > 0) {
myArrayCollection.addItemAt(aux.removeItemAt(auxLength - 1), 0);
auxLength--;
}
This is not the most accurate code, it has some strange hacks such as auxLength, not aux.length (this question gave me a range 1 exception), but at least it solved my problem.
source
share