i'm trying to sort my array but from some reason i got the following error in my compareTo function:
Cannot invoke compareTo(int) on the primitive type int
my code:
private void sortFriendList()
{
Arrays.sort(friendsList, new Comparator<FacebookUser>() {
@Override
public int compare(FacebookUser lhs, FacebookUser rhs) {
ChatMessage[] firstChatMessages = app.getDatabaseManager().getChatMessages(lhs.getId());
ChatMessage[] lastChatMessages = app.getDatabaseManager().getChatMessages(rhs.getId());
int firstLastMessageTime = (int) firstChatMessages[firstChatMessages.length-1].getTime();
int lastLastMessageTime = (int) lastChatMessages[firstChatMessages.length-1].getTime();
return firstLastMessageTime.compareTo(lastLastMessageTime);
}
});
}
the code supposed to sort an array buy time stored in long type (which i've cast to int)