JQuery - Get the minimum and maximum date and grouped it by id : I have this array of data

    [{"id":1, "start":"2018-10-10", "end":"2018-11-10"},
     {"id":1, "start":"2018-11-10", "end":"2018-12-10"},
     {"id":2, "start":"2018-11-22", "end":"2018-11-30"}]


I wanted to get the `minimum` in the start and the `maximum` in the end.

My desired output would be

    {"id":1, "start":"2018-10-10", "end":"2018-12-10"},
    {"id":2, "start":"2018-11-22", "end":"2018-11-30"}

I tried doing like this:

    data.sort((a,b) => a.start_date.toString().localeCompare(b.start_date))