Returns a sorted copy of the map, based on an optional callable
comparator. The map will be sorted by value.

@param callable|null $comparator Accepts two values to be compared.

@return \PlanB\DS\Map\MapInterface
761210
public function sorted(?callable $comparator = null): MapInterface
    {

        $items = $comparator ?
            $this->items->sorted($comparator) :
            $this->items->sorted();

        return $this->duplicate($items);
    }
609229
public static <V> V[] sort(V[] array, Comparator<? super V> comparator) {
        Arrays.sort(array, comparator);
        return array;
    }
791326
public function sort(callable $comparator = null): ArrayCollection
    {
        $items = $this->items;

        $comparator ? uasort($items, $comparator) : uasort($items, function ($a, $b) {
            return $a <=> $b;
        });

        return new static($items);
    }
1189464
public function sort(callable $comparator = null)
    {
        if ($comparator) {
            usort($this->pairs, function($a, $b) use ($comparator) {
                return $comparator($a->value, $b->value);
            });

        } else {
            usort($this->pairs, function($a, $b) {
                return $a->value <=> $b->value;
            });
        }
    }
739678
public static function compare()
    {
        $args = func_get_args();

        $operator = array_shift($args);

        return call_user_func_array(self::getComparator($operator), $args);
    }
415285
protected Comparator<RequestMapperBean> newComparator()
	{
		return new Comparator<RequestMapperBean>()
		{
			@Override
			public int compare(final RequestMapperBean o1, final RequestMapperBean o2)
			{
				return o1.getCompatibilityScore() - o2.getCompatibilityScore();
			}
		};
	}
63782
@Override
  @SuppressWarnings("unchecked")
  public <E> Comparator<E> getOrderBy() {
    return ObjectUtils.defaultIfNull(ComparatorHolder.get(), ObjectUtils.defaultIfNull(
      orderBy, ComparableComparator.INSTANCE));
  }
802794
public static ComparatorItem fromSortOrder(Sort.Order sortOrder) {
    if (sortOrder == null || sortOrder.getProperty() == null
        || sortOrder.getProperty().trim().length() == 0) {
      return null;
    }
    boolean nullIsFirst = Sort.NullHandling.NULLS_FIRST.equals(sortOrder.getNullHandling());
    return new ComparatorItem(sortOrder.getProperty(), sortOrder.isAscending(),
        sortOrder.isIgnoreCase(),
        nullIsFirst);
  }
542908
@ReplacedBy("com.google.common.collect.Ordering.natural().nullsLast()")
    public static final <T extends Comparable<?>> Comparator<T> comparable ()
    {
        @SuppressWarnings("unchecked") Comparator<T> comp = (Comparator<T>)COMPARABLE;
        return comp;
    }
8218
@CheckResult
    @NonNull
    public final Data<T> sort(@NonNull Comparator<? super T> comparator) {
        return new SortData<>(this, comparator);
    }
837456
public function sort(callable $compareFunction = null)
    {
        if (is_null($compareFunction) === true) {
            $compareFunction = function ($a, $b) {
                return $a > $b;
            };
        }
        $array = $this->getArrayCopy();
        usort($array, $compareFunction);
        $this->exchangeArray($array);

        return $this;
    }
1184926
public function sortByKey(ComparerInterface $comparer = null)
    {
        if ($comparer === null) {
            $comparer = $this->getDefaultComparer();
        }
        uksort($this->container, array($comparer, 'compare'));

        return $this;
    }
790555
public function activeSorter()
    {
        if (empty($sorter = $this->getSorter())) {
            return null;
        }

        $sorter = $this->sorters[$sorter];

        if ($sorter instanceof DirectionalSorterInterface) {
            return $sorter->withDirection($this->activeState()->sortDirection());
        }

        return clone $sorter;
    }
1101031
public function withSeparator(string $separator): self
    {
        if ($separator === $this->separator) {
            return $this;
        }

        $clone = clone $this;
        $clone->separator = $this->filterSeparator($separator);

        return $clone;
    }
912264
public function map($map = null) {
		if ($map !== null) {
			$this->_map = $map;
			return $this;
		}
		return $this->_map;
	}
1197336
public function sort(callable $sorter = null)
    {
        if (!$sorter) {
            $sorter = function ($a, $b) {
                if ($a == $b) {
                    return 0;
                }

                return ($a < $b) ? -1 : 1;
            };
        }

        usort($this->source, $sorter);

        return $this;
    }
552349
public function sort(?callable $comparator = null): Sequence
    {
        $comparator ?
            $this->items->sort($comparator) :
            $this->items->sort();

        return $this;
    }