You are here

function _gm3_region_field_array_sort in Google Maps API V3 7

Sort the array

1 string reference to '_gm3_region_field_array_sort'
_gm3_region_field_get_options in gm3_region/gm3_region_field/gm3_region_field.module
Helper function to get the options for the region field.

File

gm3_region/gm3_region_field/gm3_region_field.module, line 261

Code

function _gm3_region_field_array_sort($a, $b) {
  $a = explode(":", $a);
  $b = explode(":", $b);
  if ($a[0] != $b[0]) {
    return $a[0] > $b[0];
  }
  if (isset($a[1]) && isset($b[1])) {
    if ($a[1] != $b[1]) {
      return $a[1] > $b[1];
    }
  }
  else {
    return count($a) > count($b);
  }
  if (isset($a[2]) && isset($b[2])) {
    if ($a[2] != $b[2]) {
      return $a[2] > $b[2];
    }
  }
  else {
    return count($a) > count($b);
  }
  if (isset($a[3]) && isset($b[3])) {
    if ($a[3] != $b[3]) {
      return $a[3] > $b[3];
    }
  }
  else {
    return count($a) > count($b);
  }
}