Sort array of objects into ascending order : <p>I have an array of objects. Each object has a key "username".</p>

<p>Is there a swift way of sorting this array of objects into ascending order?</p>

<pre><code>(array(at: indexPath.row) as AnyObject).value(forKey: "username") as? String)!
</code></pre>

<p>Thanks</p>
