original_string: protected function yearSort($a, $b)
      {
          $aDates = $this->extractNewestDates($a);
          $bDates = $this->extractNewestDates($b);
  
          if (count($aDates) > 0 && count($bDates) > 0) {
              return $bDates[0] - $aDates[0];
          } elseif (count($aDates) > 0 && count($bDates) === 0) {
              return -1;
          } elseif (count($aDates) === 0 && count($bDates) > 0) {
              return 1;
          } else {
              return 0;
          }
      }
code: protected function yearSort($a, $b)
      {
          $aDates = $this->extractNewestDates($a);
          $bDates = $this->extractNewestDates($b);
  
          if (count($aDates) > 0 && count($bDates) > 0) {
              return $bDates[0] - $aDates[0];
          } elseif (count($aDates) > 0 && count($bDates) === 0) {
              return -1;
          } elseif (count($aDates) === 0 && count($bDates) > 0) {
              return 1;
          } else {
              return 0;
          }
      }
code_tokens: protected function yearSort ( $ a , $ b ) { $ aDates = $ this -> extractNewestDates ( $ a ) ; $ bDates = $ this -> extractNewestDates ( $ b ) ; if ( count ( $ aDates ) > 0 && count ( $ bDates ) > 0 ) { return $ bDates [ 0 ] - $ aDates [ 0 ] ; } elseif ( count ( $ aDates ) > 0 && count ( $ bDates ) === 0 ) { return - 1 ; } elseif ( count ( $ aDates ) === 0 && count ( $ bDates ) > 0 ) { return 1 ; } else { return 0 ; } }
docstring: Auxiliary sort function for sorting records and locations based
  on their 'date' field with the newest item being first and undefined
  dates last.
  
  @param array $a location or full pazpar2 record
  @param array $b location or full pazpar2 record
  @return int
docstring_tokens: Auxiliary sort function for sorting records and locations based on their date field with the newest item being first and undefined dates last .