title: Swift: Reading plist - How to filter by key and read and append value only
body: <p>Swift 3</p>
  
  <p>I'm trying to read a plist file to update my array for collection view.</p>
  
  <p>My <code>menu.plist</code> has 6 items that I want to read and append to my array that uses <code>.count</code> to update the collection view.</p>
  
  <p>Problem is I'm having trouble sorting the dictionary. I want to append the strings in value to my array but sort the transfer by the key which has the text "Item 0", "Item 1", etc. Because the array comes unorganized which makes it harder to use the switch statements on <code>didSelectItemAt</code>.</p>
  
  <p>In the code I'm not using <code>key</code> only appending <code>value</code> to <code>mainGroup</code> array but its unorganized and I need to filter it by the plist <code>key</code></p>
  
  <p>Code in ViewDidLoad</p>
  
  <pre><code>var mainGroup = [String]()
  
  var myDict: NSDictionary?
  if let path = Bundle.main.path(forResource: "menu", ofType: "plist") {
      myDict = NSDictionary(contentsOfFile: path)
  }
  if let dict = myDict {
  
      print(dict)
  
      for (_, value) in dict {
  
          mainGroup.append("\(value)")
      }
  
      print(mainGroup)
  }
  </code></pre>
  
  <p>Plist</p>
  
  <p><a href="https://i.stack.imgur.com/Gqm0h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gqm0h.png" alt="pic 1"></a></p>