```
var monthYear = ["Jan-2016", "Jul-2015", "Jul-2016", "Mar-2016", "Aug-2016", "Mar-2015"];

```

I wanted it to be sorted :

```
[ "Mar-2015", "Jul-2015", "Jan-2016", "Mar-2016", "Jul-2016", "Aug-2016" ]

```

Code that I m following

```
var sorted = monthYear.sort(function(a,b) {
    a = a.split("-");
    b = b.split("-")
    return new Date(a[1], a[0], 1) - new Date(b[1], b[0], 1)
});

```