- //Sort the conversations. This is a bit complicated as we need to sort by $conversation->timecreated
- //and there may be multiple conversations with the same timecreated value.
- //The conversations array contains both read and unread messages (different tables) so sorting by ID won't work
- usort($conversations, "conversationsort");
+ // Sort the conversations by $conversation->timecreated, newest to oldest
+ // There may be multiple conversations with the same timecreated
+ // The conversations array contains both read and unread messages (different tables) so sorting by ID won't work
+ $result = collatorlib::asort_objects_by_property($conversations, 'timecreated', collatorlib::SORT_NUMERIC);
+ $conversations = array_reverse($conversations);