title: Swift - need to sort an array of string days of week
body: <p>Swift 4 </p>
  
  <p>I have an array that will have random days of the week text in it. For example</p>
  
  <pre><code>var daysOfWeek: [String] = [] // ["Tuesday", "Thursday" , "Sunday", "Friday"]
  </code></pre>
  
  <p>I want to be able to sort them like: Sunday, Monday, Tuesday, ect...</p>
  
  <p>Im not sure if this is the right approach, but I tried this..</p>
  
  <pre><code>     let dateFormatter = DateFormatter()
  
      for element in daysOfWeek {
  
          print(dateFormatter.weekdaySymbols[element])
      }
  </code></pre>
  
  <p>Which throws an error:</p>
  
  <pre><code>value of optional type '[String]?' must be unwrapped to refer to member 'subscript' of wrapped base type
  </code></pre>
  
  <p>Im fairly new to Xcode and Swift</p>
  
  <p>Is this the right way to do it? if so, how can I fix the error?</p>
  
  <p>If this isn't the right way to do it, then what is?
  I appreciate any help</p>