Filter and sort swift array
<p>I have a swift array which I want to filter, here is the array</p>

<pre><code>let array = [apple,workshops,shopping,sports,parties,pantry,pen] 
</code></pre>

<p>I want to filter the array in such a way that the <strong>items beginning with the search string to appear before items that just contain the search string</strong></p>

<p>So when i search for example p, then the results should be in some way</p>

<pre><code>let array = [parties,pantry,pen,apple,workshops,shopping,sports] 
</code></pre>

<p>I tried this</p>

<pre><code>tagSearchResults = tagSearchResults.filter({ (interestTag:InterestTag) -&gt; Bool in
            let tmp: NSString = interestTag.tag
            let range = tmp.rangeOfString(searchText, options: NSStringCompareOptions.CaseInsensitiveSearch)
            return range.location != NSNotFound
        })
</code></pre>

<p>but this gives me all strings containing the search string.</p>

<p>So guys how can i do this</p>