i have an array in that array there are 2000 dictionary and i want to find out the duplicates in that array.
let contacts = [
Contact(name: "siddhant", phone: "1234"),
Contact(name: "nitesh", phone: "1234"),
Contact(name: "nitin", phone: "2222"),
Contact(name: "himanshu", phone: "2222"),
Contact(name: "kedar", phone: "3333")
]
// output should be:
[
Contact(name: "siddhant", phone: "1234"),
Contact(name: "nitesh", phone: "1234"),
Contact(name: "nitin", phone: "2222"),
Contact(name: "himanshu", phone: "2222")
]
Here's what I've tried:-
let result = values.filter { value in values.filter({ $0.phone == value.phone }).count > 1 }
print(result) //this takes lot time to filter 2000+ datas