I altered some things in your example ViewController.swift to give you the perspective I'm facing, those were the changes:
var titleArray = ["GIOVANNIJ","MARCO","IBITCI","GOD","DID","RUAN","APPEND","BIAJ","LELE","TETE"]
func generateCardInfo (cardCount:Int) -> [AnyObject] {
    var arr = [AnyObject]()
    let xibName = ["CardA"]//,"CardB","CardC"]
    
    for _ in 1...cardCount {
        let value = Int(arc4random_uniform(UInt32(xibName.count)))
        arr.append(xibName[value] as AnyObject)
    }
    return arr
}
func cardView(collectionView:UICollectionView,item:AnyObject,indexPath:IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: item as! String, for: indexPath )
    switch cell {
        case let c as CardACell:
            c.txtView.text = "Hello This is MMCardView ,Its a demo with different Card Type,This is a text type"
        
            c.labTitle.text = titleArray[indexPath.row]
        
        case let c as CardBCell:
            let v = Int(arc4random_uniform(5))+1
            c.imgV.image = UIImage.init(named: "image\(v)")            
        case let c as CardCCell:
            c.clickCallBack {
                if let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Second") as? SecondViewController {
                    vc.delegate = self
                    self.card.presentViewController(to: vc)
                }
            }
        default:
            return UICollectionViewCell()
    }
    return cell
}
@IBAction func filterAction () {
    let sheet = UIAlertController.init(title: "Filter", message: "Select you want to show in View", preferredStyle: .alert)
    sheet.addTextField(configurationHandler: nil)
    
    
    
    let byText = UIAlertAction(title: "Filter by text", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
        self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
            let titleTxt = self.titleArray[idex]
            return titleTxt.lowercased().contains(sheet.textFields![0].text!)
        })
    })
    
    /*let cellA = UIAlertAction(title: "CellA", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
        self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
            return (obj as! String) == "CardA"
        })
    })
    
    let cellB = UIAlertAction(title: "CellB", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
        
        self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
            return (obj as! String) == "CardB"
        })
    })
    
    let cellC = UIAlertAction(title: "CellC", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
        self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
            return (obj as! String) == "CardC"
        })
    })
    let ac = ["CardA","CardC"]
    let cellAC = UIAlertAction(title: "CellA,CellC", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
        
        
        self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
            return ac.contains(obj as! String)
        })
    })*/
    
    let allCell = UIAlertAction(title: "Show all cells", style: .default, handler: {
        (alert: UIAlertAction!) -> Void in
       self.card.showAllData()
    })
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
        (alert: UIAlertAction!) -> Void in
    })
            
    //sheet.addAction(cellA)
    sheet.addAction(byText)
    /*sheet.addAction(cellB)
    sheet.addAction(cellC)
    sheet.addAction(cellAC)*/
    sheet.addAction(allCell)
    sheet.addAction(cancelAction)
    self.present(sheet, animated: true, completion: nil)
}
Now this is what I'm facing:
- You have a pile of the same type cards differentiating them only by some sort of text (all of these are stored in an array).
 
- You choose to filter those cards by some text, looking for the cards that contains that text you typed.
 
- The filtering is done properly.
 
- You choose to show all your cards, to go back to the original state.
 
- Apparently everything is okay, but some cards are duplicated and some are missing.
 
Can you help me with this?