jI have an array of objects with children objects.
I want to sort my array into an array of arrays based on the children objects
For instance: Array of
[employee, employee, employee, employee]
now what I want to do is sort this like this ->
[[employee.job.jobName = "baker",employee.job.jobName = "baker"],
[employee.job.jobName = "sweeper",employee.job.jobName = "sweeper"]]
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.
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!
let sortedArray = yourArray.sort{$0.job < $1.job}orfilter{$0.job == "baker"}employeeobjects by theirjob? If so does the order of employees within each array or the order of those arrays of employees with the same job matter?