--- In flexcoders@yahoogroups.com, bjorn <[EMAIL PROTECTED]> wrote: > > I experienced some problems with ArrayCollection's removeItemAt(). It seemed > to work... randomly. > > Tucked away in the documentation i found this little gem: > "Note: If you use the ICollectionView interface to sort or filter a > collection, do not use the IList interface to manipulate the data, because > the results are indeterminate." > > My problem, of course, was that I had a sort on the ac, and that I used > IList's removeItemAt(). > > I don't understand the rationale behind this, maybe someone can explain to > me why it's difficult to implement removeItemAt() on a > sorted ArrayCollection ... I mean, I _am_ working with sorted data here, so > when I say index 11 I mean index 11 on the sorted data. That's the data I > see, that's the data I'm using, I don't need to know anything about the > underlying Array and the element's _real index_ ....the ArrayCollection > knows which element this refers to in the underlying Array, so there > shouldn't be a problem ...? > > Anyway, given the restraints we're working with here - what is the best way > to approach this? I need to be able to remove items from a sorted > ArrayCollection - any best practices?
I usually use either a one or more other ArrayCollections or ListCollectionViews with a pointer to the same data to do filtering and sorting on. Although often that's just because I want to preserve the original order as much as anything.