Problem:
– when we use datagrid to add new item and edit item directly on grid.
If you don’t sort on datagrid. Everything is ok.
But when you sort on datagrid:
– Adding new Item. The position of new Item will change follow sort.
– And after that. We use another button to Save new Item or item to edit.
The data saved will wrong.Because when save click. the position change again.

Solution:
We create new class extends Sort class of Flex.
Override function findItem() return the position you want.

EX:
public override function findItem(items : Array, values : Object, mode : String, returnInsertionIndex : Boolean =
false, compareFunction : Function = null) : int {
if (_enableSort) {
return super.findItem(items, values, mode, returnInsertionIndex, compareFunction);
} else if (_editedIndex != -1) {
return _editedIndex;
} else
return items.length;
}