I have a list of months that are pulled into my Vue app. I would like to display them in chronological order. Jan, Feb, March etc
I have read another post that shows a way to do this if you just use the data from the page.
data: function () {
return {
monthNames: [
{ month: "January", position: "01" },
{ month: "February", position: "02" },
{ month: "March", position: "03" },
{ month: "April", position: "04" },
{ month: "May", position: "05" },
{ month: "June", position: "06" },
{ month: "July", position: "07" },
{ month: "August", position: "08" },
{ month: "September", position: "09" },
{ month: "October", position: "10" },
{ month: "November", position: "11" },
{ month: "December", position: "12" },
],
This is part of the method I use to split and sort the data which is pulled in using an Axios request. It sorts it in alphabetical order though.
methods: {
let startdate = [];
metastartdate.forEach((item) => {
const splitArr = item.split(", ");
startdate = startdate.concat(splitArr).sort();
});
Can anyone help me to work this out?