static void _DoSwap(BList& list, int32 firstIndex, int32 secondIndex, BList* firstItems, BList* secondItems) { BListItem* item = (BListItem*)list.ItemAt(firstIndex); list.SwapItems(firstIndex, secondIndex); list.RemoveItems(secondIndex + 1, secondItems->CountItems()); list.RemoveItems(firstIndex + 1, firstItems->CountItems()); list.AddList(secondItems, firstIndex + 1); int32 newIndex = list.IndexOf(item); if (newIndex + 1 < list.CountItems()) list.AddList(firstItems, newIndex + 1); else list.AddList(firstItems); }