I would like to sort some data im receiving in the following structure by timestamp:
{
art_AYNgc8KwfbewFawAsogtH1Eii5eu7kKfjM3CrEpFhzWY: [
timestamp: '1613713166629',
art_type: 'Type: image/jpeg - Size: 6442.15 Ko - Dimensions: 4000 x 6000 px',
art_name: 'Name 1',
],
art_FJPKZQKfkfzNnF6AZRiayzVdKEyCg3ZJc4Kb6hTEZMUH: [
timestamp: '1613868065000',
art_type: 'Type: image/png - Size: 8475.15 Ko - Dimensions: 3000 x 2000 px',
art_name: 'Name 2',
],
art_HNXph9RtNC9MT7oK2oCvVboyEUUf8bKQLvhQbpyVRbKR: [
timestamp: '1613799567000',
art_type: 'Type: image/jpg - Size: 3475.15 Ko - Dimensions: 1500 x 1000 px',
art_name: 'Name 3'
]
}
But while keeping the exact same data structure in the result (object with key value).
I tried the following:
let sortedData = Object.values(entryData ).sort(function(a,b){
return new Date(b.timestamp) - new Date(a.timestamp);
});
Problem is i get a different structure (array vs object):
[
[
timestamp: '1613713166629',
art_type: 'Type: image/jpeg - Size: 6442.15 Ko - Dimensions: 4000 x 6000 px',
art_name: 'Name 1',
],
[
timestamp: '1613799567000',
art_type: 'Type: image/jpg - Size: 3475.15 Ko - Dimensions: 1500 x 1000 px',
art_name: 'Name 3'
],
[
timestamp: '1613868065000',
art_type: 'Type: image/png - Size: 8475.15 Ko - Dimensions: 3000 x 2000 px',
art_name: 'Name 2',
]
]
Thank you in advance for the help.