Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed sorting

  • Loading branch information...
commit 699ec5bb24c0c905af1db63124741a11ce88de04 1 parent d9614fb
@skidding authored
Showing with 10 additions and 7 deletions.
  1. +10 −7 city.php
View
17 city.php
@@ -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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.