Sort Array
Hi,
I have a local storage model that includes the following items
Order (number)
Title (string)
I'm successfully mapping the populated array to a list, however I would like to sort this list by "Order".
How is this done?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Hi,
I have a local storage model that includes the following items
Order (number)
Title (string)
I'm successfully mapping the populated array to a list, however I would like to sort this list by "Order".
How is this done?
Sorry my mistake...it's working fine running this before mapping
-------------------------var MenuItemArray = Apperyio.storage.MenuItemArray.get();
function compare(a,b) {
if (a.Order < b.Order)
return -1;
if (a.Order b.Order)
return 1;
return 0;
}
MenuItemArray.sort(compare);
Apperyio.storage.MenuItemArray.set(MenuItemArray);
-------------------------Hello,
Thank you for update! Glad it works now!