We can change the order of the Menu Tree in My Account using the extension only for mobile devices. Here we are using the index value for sorting.
//Updating the order for Menu Tree in My account
_.extend(HeaderMenuMyAccountView.prototype, {
getContext: _.wrap(HeaderMenuMyAccountView.prototype.getContext, function getContext(fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
try{
var indexChange = _.each(context.entries, function (entries) {
if (entries.name === 'Wishlist') {
entries.index = 7;
}
if (entries.name === 'Cases') {
entries.index = 11;
}
});
var sortedArray = _.sortBy(indexChange, function (IndexNumber) {
return IndexNumber.index;
});
context.entries = sortedArray;
}
catch(error)
{
console.log('error in menu tree',error)
}
return context;
})
});