I have declared an Array
like :
var sessionsToDisplayTemp : [SessionData] = []
The value of sessionsToDisplayTemp
is:
[<SessionData: 0x600001c16a30> (entity: SessionData; id: 0x8b2a8ba144e57f29 <x-coredata://0A752C13-D33E-4AE2-BE3E-7B856C0EE8D9/SessionData/p3> ; data: {
startTime = "14:30";
switchInGroup = FALSE;
}), <SessionData: 0x600001c16a80> (entity: SessionData; id: 0x8b2a8ba144f97f29 <x-coredata://0A752C13-D33E-4AE2-BE3E-7B856C0EE8D9/SessionData/p4> ; data: {
startTime = "13:30";
switchInGroup = TRUE;
}), <SessionData: 0x600001c16cb0> (entity: SessionData; id: 0x8b2a8ba144fd7f29 <x-coredata://0A752C13-D33E-4AE2-BE3E-7B856C0EE8D9/SessionData/p5> ; data: {
startTime = "13:30";
switchInGroup = FALSE;
})]
My problem is I have to check the Start time, if the start time will be same then have to hide from this array and this array should be in the order of Start Time. I mean the final array should be :
[<SessionData: 0x600001c16a30> (entity: SessionData; id: 0x8b2a8ba144e57f29 <x-coredata://0A752C13-D33E-4AE2-BE3E-7B856C0EE8D9/SessionData/p3> ; data: {
startTime = "13:30";
switchInGroup = TRUE;
}), <SessionData: 0x600001c16a80> (entity: SessionData; id: 0x8b2a8ba144f97f29 <x-coredata://0A752C13-D33E-4AE2-BE3E-7B856C0EE8D9/SessionData/p4> ; data: {
startTime = "14:30";
switchInGroup = FALSE;
})]
I have done the ascending part based on Start time using :
sessionsToDisplayTemp.sort(by: { $0.startTime?.compare(($1.startTime)!) == .orderedAscending })
Can anyone help me to achieve this. Thank you.