I want to pass data array that is coming from function to sort. For example :
const DEFAULT_COMPETITORS = [ 'Seamless/Grubhub', 'test'];
DEFAULT_COMPETITORS.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
Above is working fine. But I want data from function instead of DEFAULT_COMPETITORS
const. I want like below:
My data is coming in getAllCompetitors
instead of const.
function getAllCompetitors() {
$.ajax({
url: '/salescrm/getTopCompetitorsList',
type: 'POST',
success: function(data) {
console.log('getAllCompetitors data: ',data);
response(data);
},
error: function(data) {
console.log('data error: ',data);
}
});
}
getAllCompetitors.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
Hope you guys got.. could any please help me
Thanks in advance,