Name = $categoryRecord->Name; $this->Calendars = array_map( function($calendarRecord) { $dto = new CalendarDTO(); $dto->loadRecord($calendarRecord); return $dto; }, array_filter( $calendars, function($calendarRecord) use($categoryRecord) { return $categoryRecord->ID == $calendarRecord->CategoryID; } ) ); usort($this->Calendars, ['CalendarDTO', '__compare']); } public static function __compare(CalendarGroupDTO $cat1, CalendarGroupDTO $cat2) { return strcmp($cat1->Name, $cat2->Name); } } ?>