Swift iOS - Filter array into array of array like objects
<p>jI have an array of objects with children objects.</p>

<p>I want to sort my array into an array of arrays based on the children objects</p>

<p>For instance: Array of </p>

<pre><code>[employee, employee, employee, employee]
</code></pre>

<p>now what I want to do is sort this like this -></p>

<pre><code>[[employee.job.jobName = "baker",employee.job.jobName = "baker"],
[employee.job.jobName = "sweeper",employee.job.jobName = "sweeper"]]
</code></pre>

<p>The goal is to create a tableview where the section heading groups the employees where their job.jobName is the same. and the rows will be made up of those employees, their names etc. In order to do this, I need an array of unique job.jobNames for employees that make up the section count and then the array of employees within each section make up the row count.</p>

<p>I have tried using array.map and array.filter but I think I need a combination and  I can't seem to work my head around this one. Any help would be greatly appreciated!</p>