Ds\Vector::sorted() 函数可以返回一个排序的副本。
用法
public Ds\Vector Ds\Vector::sorted([ callable $comparator ] )
Ds\Vector::sorted() 函数可以使用可选的比较器函数返回一个排序副本。
Ds\Vector::sorted() 函数可以返回向量的排序副本。
例子1
<?php
$vector = new \Ds\Vector([6, 5, 4, 3, 2, 1]);
echo("The original vector:\n");
var_dump($vector);
$result = $vector->sorted();
echo("\n The sorted elements:\n");
var_dump($result);
?>
例子2
<?php
$vector = new \Ds\Vector([2, 5, 8, 1, 4, 7]);
echo("The original vector:\n");
var_dump($vector);
$result = $array->sorted(function($element1, $element2) {
return $element1 <=> $element2;
});
echo("\n The sorted elements:\n");
var_dump($result);
?>
相关用法
- PHP Ds Vector sort()用法及代码示例
- PHP Ds Vector sum()用法及代码示例
- PHP Ds Vector set()用法及代码示例
- PHP Ds Vector slice()用法及代码示例
- PHP Ds Vector allocate()用法及代码示例
- PHP Ds Vector get()用法及代码示例
- PHP Ds Vector count()用法及代码示例
- PHP Ds Vector unshift()用法及代码示例
- PHP Ds Vector rotate()用法及代码示例
- PHP Ds Vector last()用法及代码示例
- PHP Ds Vector push()用法及代码示例
- PHP Ds Vector first()用法及代码示例
- PHP Ds Vector jsonSerialize()用法及代码示例
- PHP Ds Vector insert()用法及代码示例
- PHP Ds Vector construct()用法及代码示例
- PHP Ds Vector contains()用法及代码示例
- PHP Ds Vector toArray()用法及代码示例
- PHP Ds Vector merge()用法及代码示例
- PHP Ds Vector join()用法及代码示例
注:本文由纯净天空筛选整理自 PHP - Ds Vector sorted() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。