public static function indexBy(Array $array, $property) {
    $ret = array();

    if (count($array) > 0) {
      $index = Util::castGetterFromSample($property, current($array));

      foreach ($array as $item) {
        $ret[$index($item)] = $item;
      }
    }

    return $ret;
  }