I currently have a set of data that contains an array of objects which have 12 indexs, and 2 values each.
Each one of the index contains the keys 'months' and 'year'. Months is a sub-array, and year is a string value (could easily be made a int).
I'm looking to sort my array of objects by the value of the year key
. For instance, currently, my data looks like this
0: {months: {…}, year: "2017"}
1: {months: {…}, year: "2019"}
2: {months: {…}, year: "2018"}
3: {months: {…}, year: "2011"}
4: {months: {…}, year: "2010"}
5: {months: {…}, year: "2012"}
6: {months: {…}, year: "2013"}
7: {months: {…}, year: "2015"}
8: {months: {…}, year: "2014"}
9: {months: {…}, year: "2016"}
I'm trying to sort this from years lowest -> highest. I tried using map, but I couldn't figure out the correct function. Any advice would be great, thank you.