I have a list of strings
const mylist = ["October 2020","December 2022","November 2020" ,...etc]
I would like to sort by year and month. How can I go about this without using external libraries/modules?
I have a list of strings
const mylist = ["October 2020","December 2022","November 2020" ,...etc]
I would like to sort by year and month. How can I go about this without using external libraries/modules?
Have you tried sorting?
const mylist = ["October 2020", "December 2022", "November 2020"]
const sorted = [...mylist].sort((a, b) => new Date(a) - new Date(b))
console.log(sorted)