Swift 2 TableView Sorting
<p>I have an iOS project I'm working on in Xcode 7 using Swift 2.  I have an <code>array</code> called <code>details</code> with a dictionary which includes a <code>String</code> and an <code>Int</code> value.  The <code>Int</code> is called <code>cellOrder</code> in the <code>Class</code> and the idea is to sort the <code>details</code> <code>array</code> in a <code>TableView</code> with a sort based on the <code>cellOrder</code> <code>Int</code> value.</p>

<p>The array shows the <code>String</code> values which are names.  I looked <a href="https://stackoverflow.com/questions/24130026/swift-how-to-sort-array-of-custom-objects-by-property-value">here</a> to try and implement this into my project with no success.</p>

<p>Here is my array:</p>

<pre><code>// Array of data for the TableView
var details = [ProjectDetails]()
</code></pre>

<p>Here is my <code>TableView</code> Code:    </p>

<pre><code>func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {

    return 1

}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {

    return details.count

}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

    cell.textLabel!.text = details[indexPath.row]        

    return cell

}
</code></pre>

<p>How do I do the sort and where would I put the code, <code>ViewDidLoad()</code> or maybe <code>cellForRowAtIndexPath</code>?</p>

<p><strong>UPDATE</strong>:</p>

<p>My <code>ViewDidLoad()</code>:</p>

<pre><code>override func viewDidLoad() {
    super.viewDidLoad()

    // TableView Sorting
    details.sortInPlace({$0.cellOrder &lt; $1.cellOrder})

    tableView.delegate = self

    ...

}
</code></pre>

<p><strong>Update 2</strong>:</p>

<p>My <code>ProjectDetails</code> <code>class</code> for the <code>array</code> data is:</p>

<pre><code>import UIKit

class ProjectDetails: NSObject, NSCoding {

    // MARK: Properties

    var fileName: String
    var cellOrder: Int

    ...

}
</code></pre>