Is there a way I can do this? In my code snippet below, this
doesn't have access to sortByName
FN when called from within sortByLyncStatus
prototype defn:
sortByName: function (bud, light) {
if (bud.FullName < light.FullName)
return -1;
if (bud.FullName > light.FullName)
return 1;
return 0;
},
sortByLyncStatus: function (chuck, norris) {
if (chuck.LyncAvailability == "Available" && norris.LyncAvailability == "Available") {
return this.sortByName(chuck, norris);
}
else {
if (chuck.LyncAvailability == "Available")
return -1;
if (norris.LyncAvailability == "Available")
return 1;
else { // both are away, inactive, offline, or out of office
var chuckLastActive = $.toDateFromJson(chuck.LyncLastActive);
var norrisLastActive = $.toDateFromJson(norris.LyncLastActive);
if (chuckLastActive < norrisLastActive)
return 1;
if (chuckLastActive > norrisLastActive)
return -1;
return this.sortByName(chuck, norris);
}
}
}
solution
some.prototype.obj = {
sortByName: function (a, b) {
// omitted for solution
},
sortByLyncStatus: function(a, b) {
// compare cases
// default to name comparison
return some.prototype.obj.sortByName(a, b);
}
}