title: Swift: Get indices of an array of objects filtered by a certain property
body: <p>I have an array of custom objects, having ID values as properties. Now I have another array of selected objects (selected by IDs). How can I get the indices of the first array by filtering for the selected IDs (second array)?</p>
  
  <p>I would like to avoid looping and think of a solution using <code>compactMap</code> or similar.</p>
  
  <pre><code>struct MyObject {
      var ID: Int
      var name: String
  }
  
  let myObjects = [
      MyObject(ID: 3, name: "AAAA"),
      MyObject(ID: 5, name: "BBBB"),
      MyObject(ID: 12, name: "CCCC"),
      MyObject(ID: 15, name: "DDDD"),
      MyObject(ID: 20, name: "EEEE"),
      MyObject(ID: 21, name: "GGGG"),
      MyObject(ID: 22, name: "HHHH"),
      MyObject(ID: 23, name: "IIII"),
  ]
  let selectedIds = [5, 20, 23]
  
  // How to get an array of indices for selectedIds
  // Expected result [1, 4, 7]
  </code></pre>