code: public function getAccompanyingPeriodsOrdered() {
          $periods = $this->getAccompanyingPeriods()->toArray();
          
          //order by date :
          usort($periods, function($a, $b) {
              $dateA = $a->getOpeningDate();
              $dateB = $b->getOpeningDate();
              
              if ($dateA == $dateB) {
                  $dateEA = $a->getClosingDate();
                  $dateEB = $b->getClosingDate();
                  
                  if ($dateEA == $dateEB) {
                      return 0;
                  }
                  
                  if ($dateEA < $dateEB) {
                      return -1;
                  } else {
                      return +1;
                  }
              }
              
              if ($dateA < $dateB) {
                  return -1 ;
              } else {
                  return 1;
              }
          });    
                  
          return $periods;
      }
docs: Get the accompanying periods of a give person with the
  chronological order.
  
  @return AccompanyingPeriod[]