const vehicle = [
{ type: 'car', color: 'Red' },
{ type: 'car', color: 'Blue' },
{ type: 'truck', color: 'Black' } ]
vehicle.sort((a, b) => a.type.localeCompare(b.type));
//vehicle.sort(compareFn:(a :vehicle, b :vehicle) => a.type.localeCompare(b.type));