I have an array of objects as follows :
let cars = [
{\"id\":20,\"mileage\":41300,\"make\":\"Golf\", initialRegistration:\"09/02/2010\"},
{\"id\":21
Actually the date parsing was not happening correctly new Date("09/02/2010") will not work and will assume date to be 2nd sep 2010 hence it need sto be passed as "2010-02-09" yyyy-mm-dd
let sortedCars = cars.sort((a, b) => Date.parse(new Date(a.initialRegistration.split("/").reverse().join("-"))) - Date.parse(new Date(b.initialRegistration.split("/").reverse().join("-"))));
See this http://jsfiddle.net/jwm6k66c/1590/
Your sorting way is proper, just change the date format in cars array, make it MM:DD:YYYY, or YYYY:MM:DD it will work, because these are the formats that Date parse accept.
Use Date constructor and do something like this.
let sortedCars1 = cars.sort((a, b) => new Date(...a.initialRegistration.split('/').reverse()) - new Date(...b.initialRegistration.split('/').reverse()));
let cars = [{
"id": 20,
"mileage": 41300,
"make": "Golf",
initialRegistration: "09/02/2010"
}, {
"id": 21,
"mileage": 51300,
"make": "Passat",
initialRegistration: "06/04/2012"
}, {
"id": 22,
"mileage": 61300,
"make": "Audi",
initialRegistration: "02/01/2018"
}, {
"id": 23,
"mileage": 20300,
"make": "Touran",
initialRegistration: "17/09/2013"
}, {
"id": 24,
"mileage": 10300,
"make": "Polo",
initialRegistration: "26/07/2014"
}];
let sortedCars1 = cars.sort((a, b) => new Date(...a.initialRegistration.split('/').reverse()) - new Date(...b.initialRegistration.split('/').reverse()));
console.log(sortedCars1);
Or by string comparison using String#localeCompare after reversing the date string.
let sortedCars1 = cars.sort((a, b) =>
a.initialRegistration.split('/').reverse().join().localeCompare(b.initialRegistration.split('/').reverse().join()));
let cars = [{
"id": 20,
"mileage": 41300,
"make": "Golf",
initialRegistration: "09/02/2010"
}, {
"id": 21,
"mileage": 51300,
"make": "Passat",
initialRegistration: "06/04/2012"
}, {
"id": 22,
"mileage": 61300,
"make": "Audi",
initialRegistration: "02/01/2018"
}, {
"id": 23,
"mileage": 20300,
"make": "Touran",
initialRegistration: "17/09/2013"
}, {
"id": 24,
"mileage": 10300,
"make": "Polo",
initialRegistration: "26/07/2014"
}];
let sortedCars1 = cars.sort((a, b) =>
a.initialRegistration.split('/').reverse().join().localeCompare(b.initialRegistration.split('/').reverse().join()));
console.log(sortedCars1);