noganno
9/2/2013 - 5:51 PM

Сортировка массива по значению

Сортировка массива по значению

[0] => Array
        (
            [IBLOCK_ELEMENT_ID] => 636
            [VALUE] => П
            [IBLOCK_SECTION_ID] => 1
        )
 
    [1] => Array
        (
            [IBLOCK_ELEMENT_ID] => 616
            [VALUE] => 750
            [IBLOCK_SECTION_ID] => 1
        )
 
    [2] => Array
        (
            [IBLOCK_ELEMENT_ID] => 583
            [VALUE] => 500
            [IBLOCK_SECTION_ID] => 1
        )
 
    [3] => Array
        (
            [IBLOCK_ELEMENT_ID] => 555
            [VALUE] => 330
            [IBLOCK_SECTION_ID] => 1
        )
 
function array_sort_by_field(&$arr, $fieldname, $sort_order = SORT_ASC, $sort_type = SORT_REGULAR) { 
  	foreach($arr as $val) $sortAux[] = $val[$fieldname]; 
		array_multisort($sortAux, $sort_order, $sort_type, $arr); 
		return $arr; 
		} 
 
		$test = array_sort_by_field($array_property, 'VALUE', SORT_DESC); 
 
	   echo '<pre>';
			print_r($array_property);
	   echo '</pre>';