Blame view

class_mcSort.inc.php 800 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<?php
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;
		}
	}		
}
	
?>