class_mcSort.inc.php 846 Bytes
<?php
/** 
 * @copyright (c) 2014, netz.coop eG
 */
class mcSort {
	public static function sortObjs(array $param_objs, $param_column) {

		$objs = $param_objs;
		$RelationObjcts_count = count($objs);
		
		if(is_array($objs) && !empty($objs)) {
			
			$tmp_sort_short = array();
			foreach($objs as $key => $Relation) {
				$tmp_sort_short[$key] = $Relation->$param_column;
			}
			asort($tmp_sort_short);
			
			$tmp_sort_objects = array();
			foreach($tmp_sort_short as $key => $column_value) {
				$tmp_sort_objects[] = $objs[$key];
			}
			$param_objs = $tmp_sort_objects;
			
			if($RelationObjcts_count == count($param_objs)) {
				return $param_objs;
			} else {
				D::li('weniger als vorher '.$param_column);
				return false;
			}
		} else {
			D::li('no Relation exists with this name '.$param_column);
			return false;
		}
	}		
}
	
?>