sort iCal compoments, only local date sort

@author Kjell-Inge Gustafsson <ical@kigkonsult.se>
@since 2.2.9 - 2007-10-02
@return sort param
195913
function _cmpfcn( $a, $b ) {
    if(  'vtimezone' == $a->objName)                   return -1;
    if(  'vtimezone' == $b->objName)                   return  1;
    if(          isset( $a->dtstart['value'] ) ||
                 isset( $b->dtstart['value'] )) {
      foreach( $this->_sortkeys as $key ) {
        if(     !isset( $a->dtstart['value'][$key] ))  return -1;
        elseif( !isset( $b->dtstart['value'][$key] ))  return  1;
        if    (         $a->dtstart['value'][$key]
                     == $b->dtstart['value'][$key] )
          continue;
        if    ((  (int) $a->dtstart['value'][$key] ) <
               (  (int) $b->dtstart['value'][$key] ))  return -1;
        elseif((  (int) $a->dtstart['value'][$key] ) >
               (  (int) $b->dtstart['value'][$key] ))  return  1;
      }
    }
    if( isset( $a->dtend['value'] ))
      $c = $a->dtend['value'];
    if(     empty( $c ) && !empty( $a->due['value'] ))
      $c = $a->due['value'];
    if(     empty( $c ) && !empty( $a->duration['value'] ))
      $c = $a->duration2date();
    if( isset( $b->dtend['value'] ))
      $d = $b->dtend['value'];
    if(     empty( $d ) && !empty( $b->due['value'] ))
      $d = $b->due['value'];
    if(     empty( $d ) && !empty( $b->duration['value'] ))
      $d = $b->duration2date();
    if(          isset( $c ) ||   isset( $d )) {
      if(       !isset( $c ) &&   isset( $d ))         return -1;
      if(        isset( $c ) &&  !isset( $d ))         return  1;
      foreach( $this->_sortkeys as $key ) {
        if    ( !isset( $c[$key] ))                    return -1;
        elseif( !isset( $d[$key] ))                    return  1;
        if    (         $c[$key]
                     == $d[$key] )
          continue;
        if    ((  (int) $c[$key] ) <
               (  (int) $d[$key] ))                    return -1;
        elseif((  (int) $c[$key] ) >
               (  (int) $d[$key] ))                    return  1;
      }
    }
    $c = ( isset( $a->created['value'] )) ? $a->created['value'] : $a->dtstamp['value'];
    $d = ( isset( $b->created['value'] )) ? $b->created['value'] : $b->dtstamp['value'];
    foreach( $this->_sortkeys as $key ) {
      if(       !isset( $a->created['value'][$key] ))  return -1;
      elseif(   !isset( $b->created['value'][$key] ))  return  1;
      if    (           $a->created['value'][$key]
                     == $b->created['value'][$key] )
        continue;
      if    ((    (int) $a->created['value'][$key] ) <
             (    (int) $b->created['value'][$key] ))  return -1;
      elseif((    (int) $a->created['value'][$key] ) >
             (    (int) $b->created['value'][$key] ))  return  1;
    }
    if    ((            $a->uid['value'] ) <
           (            $b->uid['value'] ))            return -1;
    elseif((            $a->uid['value'] ) >
           (            $b->uid['value'] ))            return  1;
    return 0;
  }
374367
private static function dateComparator(): Closure
    {
        return static function (Fact $a, Fact $b): int {
            if ($a->date()->isOK() && $b->date()->isOK()) {
                // If both events have dates, compare by date
                $ret = Date::compare($a->date(), $b->date());

                if ($ret === 0) {
                    // If dates overlap, compare by fact type
                    $ret = self::typeComparator()($a, $b);

                    // If the fact type is also the same, retain the initial order
                    if ($ret === 0) {
                        $ret = $a->sortOrder <=> $b->sortOrder;
                    }
                }

                return $ret;
            }

            // One or both events have no date - retain the initial order
            return $a->sortOrder <=> $b->sortOrder;
        };
    }
1004633
public function sort()
    {
        $index      = 0;
        $comparator = [$this->sorter, 'sort'];

        // add an index to provide stable sorting
        foreach ($this->items as &$item) {
            $item = [$index++, $item];
        }
        unset($item);

        uasort($this->items, function ($a, $b) use ($comparator) {
            $result = $comparator($a[1], $b[1]);

            // use the index to prevent undefined behaviour when comparator reports items are "equal"
            return $result === 0 ? $a[0] - $b[0] : $result;
        });

        // remove the index
        foreach ($this->items as &$item) {
            $item = $item[1];
        }
        unset($item);
    }
622949
@Override
    public Iterator<LocalDate> iterator() {

        return new Iterator<LocalDate>() {

            final IntIterator intIterator = intIterator();

            @Override
            public boolean hasNext() {
                return intIterator.hasNext();
            }

            @Override
            public LocalDate next() {
                return PackedLocalDate.asLocalDate(intIterator.nextInt());
            }
        };
    }
395890
public function sort()
    {
        array_multisort(array_map(function ($pair) {
            return mb_convert_encoding($pair[0], 'UTF-16BE', 'UTF-8');
        }, $this->list), SORT_STRING, range(1, count($this->list)), $this->list);
    }
927679
public function getSorting()
    {
        $sortOrder = $this->getRequest()->get('sortOrder', 'asc');
        $sortBy = $this->getRequest()->get('sortBy', 'id');

        return [$sortBy => $sortOrder];
    }
525942
@Override
    public int compareTo(final SortableLocation that) {

        // Check sanity
        Validate.notNull(that, "that");
        if (this == that) {
            return 0;
        }

        // Delegate
        return this.toString().compareTo(that.toString());
    }
192603
public Map<String, String> getSortParameter() {

        return new HashMap<String, String>() {{
            put(sortUrlParameterName, getFields());
        }};
    }
1307639
function DateLocaleProvider() {
      /** Array of full month names. E.g., ['January', 'February', ...] */
      this.months = null;

      /** Array of abbreviated month names. E.g., ['Jan', 'Feb', ...] */
      this.shortMonths = null;

      /** Array of full day of the week names. E.g., ['Monday', 'Tuesday', ...] */
      this.days = null;

      /** Array of abbreviated dat of the week names. E.g., ['M', 'T', ...] */
      this.shortDays = null;

      /** Array of dates of a month (1 - 31). Characters might be different in some locales. */
      this.dates = null;

      /** Index of the first day of the week. 0 = Sunday, 1 = Monday, etc. */
      this.firstDayOfWeek = 0;

      /**
       * Function that converts the date portion of a Date to a string.
       * @type {(function(Date): string)}
       */
      this.formatDate = null;

      /**
       * Function that converts a date string to a Date object (the date portion)
       * @type {function(string): Date}
       */
      this.parseDate = null;

      /**
       * Function that formats a Date into a month header string.
       * @type {function(Date): string}
       */
      this.monthHeaderFormatter = null;

      /**
       * Function that formats a week number into a label for the week.
       * @type {function(number): string}
       */
      this.weekNumberFormatter = null;

      /**
       * Function that formats a date into a long aria-label that is read
       * when the focused date changes.
       * @type {function(Date): string}
       */
      this.longDateFormatter = null;

      /**
       * Function to determine whether a string makes sense to be
       * parsed to a Date object.
       * @type {function(string): boolean}
       */
      this.isDateComplete = null;

      /**
       * ARIA label for the calendar "dialog" used in the datepicker.
       * @type {string}
       */
      this.msgCalendar = '';

      /**
       * ARIA label for the datepicker's "Open calendar" buttons.
       * @type {string}
       */
      this.msgOpenCalendar = '';
    }
296217
protected LocalDate toLocalDate(@Nullable final String inputDate) {
        return inputDate == null || inputDate.isEmpty() ? null : LocalDate.parse(inputDate, LOCAL_DATE_FORMATTER);
    }
651789
public long getSortDate() {

        long result = getDateLastModified();
        if (m_related != null) {
            for (CmsPublishResource rel : m_related) {
                result = Math.max(result, rel.getSortDate());
            }
        }
        return result;
    }
1139594
public static function date_sort_callback($a, $b) {
		if($a->StartDate == $b->StartDate) {
			if($a->StartTime == $b->StartTime)
				return 0;
			else if(strtotime($a->StartTime) > strtotime($b->StartTime))
				return 1;
			else 
				return -1;
		}
		else if(strtotime($a->StartDate) > strtotime($b->StartDate))
			return 1;
		else 
			return -1;
		
	}
1050580
public static Sort sort(Sort... sort) {
        if (sort.length == 1) {
            return sort[0];
        } else {
            Sort s = new Sort(true);
            for (Sort x : sort) {
                ((ArrayNode) s.node).add(x.toJson());
            }
            return s;
        }
    }
709164
public function sortByEndDate()
	{
		uksort( $this->contexts, function( $a, $b ) use ( &$contexts )
		{
			return -1 * strcmp( $this->contexts[ $a] ['period']['endDate'], $this->contexts[ $b]['period']['endDate'] );
		} );

		return $this;
	}
493380
public String getLocaleSeparator() {
        String sub0 = "{0}";
        String sub1 = "{1}";
        ICUResourceBundle locDispBundle = (ICUResourceBundle) langBundle.get(LOCALE_DISPLAY_PATTERN);
        String  localeSeparator = locDispBundle.getStringWithFallback(SEPARATOR);
        int index0 = localeSeparator.indexOf(sub0);
        int index1 = localeSeparator.indexOf(sub1);
        if (index0 >= 0 && index1 >= 0 && index0 <= index1) {
            return localeSeparator.substring(index0 + sub0.length(), index1);
        }
        return localeSeparator;
    }
1174375
public static function getThousandsSeparator()
    {
        if (!isset(self::$thousandsSeparator)) {
            $localeconv = localeconv();
            self::$thousandsSeparator = ($localeconv['thousands_sep'] != '')
                ? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];

            if (self::$thousandsSeparator == '') {
                // Default to .
                self::$thousandsSeparator = ',';
            }
        }
        return self::$thousandsSeparator;
    }
726293
public LocalDate letzterArbeitstag() {
        LocalDate tag = letzterTag();
        switch (tag.getDayOfWeek()) {
            case SATURDAY:
                return tag.minusDays(1);
            case SUNDAY:
                return tag.minusDays(2);
            default:
                return tag;
        }
    }