Let\'s say there are two arrays...
var array1 = [\"a\", \"b\", \"c\"]
var array2 = [\"b\", \"c\", \"a\"]
I\'d like the result of the compar
Here is a solution that does not require the element to be Comparable, but only Equatable. It is much less efficient than the sorting answers, so if your type can be made Comparable, use one of those.
extension Array where Element: Equatable {
func equalContents(to other: [Element]) -> Bool {
guard self.count == other.count else {return false}
for e in self{
guard self.filter{$0==e}.count == other.filter{$0==e}.count else {
return false
}
}
return true
}
}