usage:

$devices_array_sorted = ArrayOfArraysSort($devices_array, "AverageWatts",SORT_ASC);

the function:

/* sort array that contains a lot of arrays by key */
function ArrayOfArraysSort($array,$key,$mode)
{
    // sort by age
    $sort = array();
    foreach($array as $k=>$v) {
        $sort[$key][$k] = $v[$key];
    }
    # sort by age desc and then title asc
    array_multisort($sort[$key], $mode,$array);
    
    return $array;
}

where example array is:

Array
(
    [0] => Array
        (
            [id] => 1
            [category] => 3
            [brand] => 2
            [model] => t440
            [name] => lenovo t440
            [modes] => 1
            [happiness] => 4
            [works_since_years] => 4
            [description] => 
            [my_comment] => 
            [image] => 
            [AverageWatts] => 62.5
        )

    [1] => Array
        (
            [id] => 2
            [category] => 3
            [brand] => 7
            [model] => xps
            [name] => dell xps
            [modes] => 1,2,3
            [happiness] => 3
            [works_since_years] => 2
            [description] => 
            [my_comment] => 
            [image] => 
            [AverageWatts] => 85
        )

)
admin