title: Filter array of objects with multiple criteria and types in Swift
body: <p>I am trying to do some complex filtering in my app and I am to a point where I don't know what to do next. My data consistes of an array of dictionaries where the values in each of the dictionaries can be <code>String</code>, <code>Int</code> or <code>[String]</code>. </p>
  
  <pre><code>let person1: [String : Any] = ["first_name" : "John",
                                 "last_name" : "Smith",
                                 "age" : 21,
                                 "skills" : ["C#", "Java", "Swift"]]
  let person2: [String : Any] = ["first_name" : "Kim",
                                 "last_name" : "Smith",
                                 "age" : 28,
                                 "skills" : ["Java", "Swift"]]
  let person3: [String : Any] = ["first_name" : "Kate",
                                 "last_name" : "Bell",
                                 "age" : 24,
                                 "skills" : ["C#"]]
  
  
  var people = [person1, person2, person3]
  </code></pre>
  
  <p>I let the user choose how to filter this data and create a dictionary of filter criteria. This dictionary can have any number of keys and values.</p>
  
  <pre><code>let filters: [String : [Any]] = ["age" : [28, 24],
                                   "skills" : ["Java", "Swift"]]
  </code></pre>
  
  <p>In this example I want to show persons who are <code>age</code> 28 or 24 and have a <code>skills</code> of Java or Swift, which would be <code>person2</code></p>
  
  <p>Here is what I have so far but it only works with <code>Int</code> values:</p>
  
  <pre><code>for (key, values) in filters {
      var filteredItems = people.filter {
          var match = false
          for filterValue in values {
              if $0[key] as! Int == filterValue as! Int {
                  match = true
                  break
              }
              else {
                  match = false
              }
          }
          return match
      }
      people = filteredItems
  }
  </code></pre>