I am making a table view where you can drag and drop the cells to sort them in the right order. However, the current sorting uses the swap method. If I want to move cell 10 to cell 1, it swaps them. I don't want that. I want cell10 to move to cell1, but cell1 and the rest of them one cell downward as if we made an insertion. How can I do that? (items is the name of the array)
func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
if (sourceIndexPath.row != destinationIndexPath.row){
swap (&items[sourceIndexPath.row], &items[destinationIndexPath.row])
}
tableView.reloadData()
}