I have an array of dates, that looks something along these lines:
var dates = [
{ day: 14, month: 4 },
{ day: 28, month: 4 },
{ day: 29, month: 11 },
{ day: 2, month: 9 }
];
And I want to sort them, from the perspective that now it's August. I mean, 11th month is closer than the 4th month. I have thought about it a lot, and finally came up with this solution.
First of all, it doesn't really work, because of problems with concatenating JSON arrays, but that's a minor issue.
I think this is a pretty bad way to do this, in terms of efficiency or something. Can you come up with anything better? Thanks!