| @@ 272-279 (lines=8) @@ | ||
| 269 | public function sortBy($field, $reverse = false) |
|
| 270 | { |
|
| 271 | if ($reverse) { |
|
| 272 | $sortFunction = function ($a, $b) use ($field) { |
|
| 273 | $first = dataGet($a, $field); |
|
| 274 | $second = dataGet($b, $field); |
|
| 275 | if ($first == $second) { |
|
| 276 | return 0; |
|
| 277 | } |
|
| 278 | return ($first > $second) ? -1 : 1; |
|
| 279 | }; |
|
| 280 | } else { |
|
| 281 | $sortFunction = function ($a, $b) use ($field) { |
|
| 282 | $first = dataGet($a, $field); |
|
| @@ 281-288 (lines=8) @@ | ||
| 278 | return ($first > $second) ? -1 : 1; |
|
| 279 | }; |
|
| 280 | } else { |
|
| 281 | $sortFunction = function ($a, $b) use ($field) { |
|
| 282 | $first = dataGet($a, $field); |
|
| 283 | $second = dataGet($b, $field); |
|
| 284 | if ($first == $second) { |
|
| 285 | return 0; |
|
| 286 | } |
|
| 287 | return ($first < $second) ? -1 : 1; |
|
| 288 | }; |
|
| 289 | } |
|
| 290 | ||
| 291 | ||