Ds\Sequence::sort() 函數可以對序列進行就地排序。
用法
public abstract void Ds\Sequence::sort([ callable $comparator ] )
Ds\Sequence::sort() 函數可以使用可選的比較器函數就地對序列進行排序。
Ds\Sequence::sort() 函數不返回任何值。
例子1
<?php
$seq = new \Ds\Vector([2, 7, 1, 9, 6, 15, 12, 20]);
$seq->sort();
print_r($seq);
?>
示例2
<?php
$seq = new \Ds\Vector([2, 7, 1, 9, 6, 5, 12, 20]);
$seq->sort(function($x, $y) {
return $y <=> $x;
});
print_r($seq);
?>
相關用法
- PHP Ds Sequence sorted()用法及代碼示例
- PHP Ds Sequence slice()用法及代碼示例
- PHP Ds Sequence shift()用法及代碼示例
- PHP Ds Sequence capacity()用法及代碼示例
- PHP Ds Sequence insert()用法及代碼示例
- PHP Ds Sequence reduce()用法及代碼示例
- PHP Ds Sequence get()用法及代碼示例
- PHP Ds Sequence join()用法及代碼示例
- PHP Ds Sequence rotate()用法及代碼示例
- PHP Ds Sequence pop()用法及代碼示例
- PHP Ds Sequence remove()用法及代碼示例
- PHP Ds Sequence contains()用法及代碼示例
- PHP Ds Sequence filter()用法及代碼示例
- PHP Ds Sequence allocate()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Ds Sequence sort() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。