I have this JSON data, not sure how to call it because the JavaScript objects vs JavaScript arrays vs JSON strings confuse me a lot.
{ 'slot': 1, url: 'http://example.com'},
{ 'slot': 2, url: 'http://example.com'},
{ 'slot': 3, url: 'http://example.com'},
{ 'slot': 1, url: 'http://example.com'},
{ 'slot': 2, url: 'http://example.com'},
{ 'slot': 3, url: 'http://example.com'},
{ 'slot': 4, url: 'http://example.com'},
Is there an easy way to sort it by my slot
value so that it becomes like this: ?
{ 'slot': 1, url: 'http://example.com'},
{ 'slot': 1, url: 'http://example.com'},
{ 'slot': 2, url: 'http://example.com'},
{ 'slot': 2, url: 'http://example.com'},
{ 'slot': 3, url: 'http://example.com'},
{ 'slot': 3, url: 'http://example.com'},
{ 'slot': 4, url: 'http://example.com'},
I can probably do it by looping and creating a copy of the object/array but maybe there are some predefined sort() functions for this ?