I am working on a angular app. I have following array.
[
{
"Name": "Jack",
"IncomingTime": "2020-06-19T11:02+00:00",
"Outgoingtime": "2020-06-19T11:07+00:00",
},
{
"Name": "Mary",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T11:07+00:00",
},
{
"Name": "jolly",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T11:07+00:00",
},
{
"Name": "Jack",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T11:07+00:00",
},
{
"Name": "Maria",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T11:17+00:00",
},
{
"Name": "Maria",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T12:53+00:00",
},
{
"Name": "Jack",
"IncomingTime": "2020-06-19T11:05+00:00",
"Outgoingtime": "2020-06-19T11:07+00:00",
}
]
I want to achieve a unique array. I want to sort elements in this array such that, it should first sort all elements alphabetically by Name. If names are same, then I want to sort with Incoming time. For example person with "Name': "jack' occur three times, then Jack with early incoming time should be placed in array i.e with "2020-06-19T11:02+00:00" and rest two elements of "jack" though they have same Incoming and Outgoing time are discarded(Since we have already included one with early IncomingTime in array). If with "Name" and "IncomingTime" are also same for example for "Maria", there are only two elements and "Name","IncomingTime" are same then I want to keep the element with early Outgoing time i.e the element which should be in resulting array should be of "OutgointTime": "2020-06-19T11:17+00:00" and the other one with "OutgointTime" 12:53 is discarded. How can I achieve that?