| @@ 20-28 (lines=9) @@ | ||
| 17 | * to use the default comparer Comparer<T>.Default. |
|
| 18 | * @return $this |
|
| 19 | */ |
|
| 20 | public function sort(ComparerInterface $comparer = null) |
|
| 21 | { |
|
| 22 | if ($comparer === null) { |
|
| 23 | $comparer = $this->getDefaultComparer(); |
|
| 24 | } |
|
| 25 | usort($this->container, array($comparer, 'compare')); |
|
| 26 | ||
| 27 | return $this; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Sorts the keys in the entire Collection<T> using the specified comparer. |
|
| @@ 36-44 (lines=9) @@ | ||
| 33 | * null to use the default comparer Comparer<T>.Default. |
|
| 34 | * @return $this |
|
| 35 | */ |
|
| 36 | public function sortByKey(ComparerInterface $comparer = null) |
|
| 37 | { |
|
| 38 | if ($comparer === null) { |
|
| 39 | $comparer = $this->getDefaultComparer(); |
|
| 40 | } |
|
| 41 | uksort($this->container, array($comparer, 'compare')); |
|
| 42 | ||
| 43 | return $this; |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||