contact.sort on android
THis code works fine on iPHONE, but a.lastname is returning NULL on an ANDROID. So, I believe the problem is when the array is passed to the function.. any suggestions?
// var people = Titanium.Contacts.getAllPeople();
if (Ti.Platform.name == "android"){
Ti.API.info('-------- entering ANDROID vyinclude.js include file ----------');
function sortByFirstName(a, b) {
//var x = a.firstName.toLowerCase();
//var y = b.firstName.toLowerCase();
var x = a.lastName.toLowerCase();
var y = b.lastName.toLowerCase();
//var x = a.lastName;
//var y = b.lastName;
Ti.API.info('x = ' + x); //x and y are returning null.. so the sort is not working.
Ti.API.info('y = ' + y);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
Ti.API.info('-------- exitiing ANDROID vyinclude.js include file ----------');
};
people.sort(sortByFirstName);