I have an array that I get from an API. I need to sort the data based on the order value.
The data is kind of complex, here is an example:
const data = [{
gallery: {
id: 91,
media: [{
type: 'image',
file: 'http://xxxxx.jpg',
}],
title: 'title 3',
description: 'test',
order: 3,
is_main: false,
created_at: '2020-08-02T15:19:44.319133Z',
updated_at: '2020-08-02T16:48:06.766478Z',
}
},
{
gallery: {
id: 91,
media: [{
type: 'image',
file: 'http://xxxxx.jpg',
}],
title: 'title 2',
description: 'test',
order: 2,
is_main: false,
created_at: '2020-08-02T15:19:44.319133Z',
updated_at: '2020-08-02T16:48:06.766478Z',
}
}]
I need a way to sort the data based on the order given in the API.