예제 #1
0
  public static function compare($stop1, $stop2) {
    //first array element is the stop
    //the "bus" element is the bus number
    $stop1 = $stop1[0];
    $stop2 = $stop2[0];

    //NULL stop are at the end of time.
    if(!$stop1) {
      return 1;
    }
    
    if(!$stop2) {
      return -1;
    }

    if($stop1->day != $stop2->day) {
      return day::compare($stop1->day, $stop2->day);
    }

    if($stop1->hour != $stop2->hour) {
      return $stop1->hour > $stop2->hour ? +1 : -1;
    }

    if($stop1->minute != $stop2->minute) {
      return $stop1->minute > $stop2->minute ? +1 : -1;
    }
 
    return 0;
  }