I have a challenge sorting an array as desired;
Below is my code:
callbacks : {
onComplete : function(id, filename, response) {
handler.addImage({
uuid : response.image_id,
thumbnailUrl : response.image_url,
name : response.filename
}, id);
this.setDeleteFileParams({
id : response.image_id
}, id);
self._images.push(response.image_id); /* here */
}
}
self._images returns an array with response.image_id but they are not sorted as expected; I need the result ordered by response.filename.
The following example illustrates what I meant;
Given that:
response.image_id -> response.image_id
8870 -> img03.jpg
8889 -> img02.jpg
8875 -> img01.jpg
The result of my function will be:
Array(3)
0: 8889
1: 8875
2: 8870
Instead, this I what I would like to achieve:
Array(3)
0: 8875
1: 8889
2: 8870
What am I doing wrong and how can I fix it?