mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-16 21:01:16 +02:00
22 lines
390 B
PHP
22 lines
390 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Strategy;
|
|
|
|
$elements = array(
|
|
array(
|
|
'id' => 2,
|
|
'date' => '2011-01-01',
|
|
),
|
|
array(
|
|
'id' => 1,
|
|
'date' => '2011-02-01'
|
|
)
|
|
);
|
|
|
|
$collection = new ObjectCollection($elements);
|
|
$collection->setComparator(new IdComparator());
|
|
$collection->sort();
|
|
|
|
$collection->setComparator(new DateComparator());
|
|
$collection->sort();
|