Skip to content

Commit

Permalink
Fixed sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Feb 26, 2012
1 parent d9614fb commit 699ec5b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions city.php
Expand Up @@ -43,19 +43,22 @@ public static function get($file)
}
public static function sort($cities)
{
$first = -1;
$i = 0;
$hour = 24;

foreach($cities as $k => $city)
{
if($city->get_period() == 'morning')
if($city->get_period() != 'morning'
|| $city->get_hour() >= $hour)
{
$first = $k;

break;
continue;
}
$i = $k;

$hour = $city->get_hour();
}
$before = array_slice($cities, 0, $first);
$after = array_slice($cities, $first);
$before = array_slice($cities, 0, $i);
$after = array_slice($cities, $i);

return array_merge($after, $before);
}
Expand Down

0 comments on commit 699ec5b

Please sign in to comment.