I am trying to sort an array of objects in Angular2. The best way to explain is to give code examples:
var activity = {
SEQ_NO: -1,
SIGNUP_NAME: "Testing Activity",
SHORT_DESCRIPTION: "This activity min: 2, max: 25",
EVENT_BEGIN_DATE: "2018/09/25",
EVENT_END_DATE: "2018/09/25"
};
The array is filled with objects like seen above. My goal is to take the array and sort it based on the date. I also call a convert date function that takes the numeric date and turns it to a readable format:
convertDate(incomingDate) {
var myDate = new Date(incomingDate);
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
console.log(days[myDate.getDay()]);
var date = days[myDate.getDay()]+" "+(myDate.getMonth()+1)+'/'+myDate.getDate()+'/'+myDate.getFullYear();
//alert(date);
return date;
}
So the activity object shown in this example will convert to:
Tuesday 9/25/2018
How can I sort an array of these objects by date? When I display them, I am wanting to display them in order of months.
Thanks everyone in advanced.