$b[$key]) { return $d * 1; } if ($a[$key] < $b[$key]) { return $d * -1; } return $c; }; } else { $collator = new Collator(Contexts::get(LanguageContext::class)->getActive()->getLocale()); $sortCallable = function ($a, $b) use ($key, $d, $c, $collator) { if (($c = $collator->compare($a[$key], $b[$key])) != 0) { return $d * $c; } return $c; }; } $sortData[$key] = $sortCallable; } // create sort func $sort_func = $sort_funcs[$sortby] = function ($a, $b) use ($sortData) { foreach ($sortData as $key => $callable) { return $callable($a, $b); } return 0; }; } else { $sort_func = $sort_funcs[$sortby]; } uasort($data, $sort_func); } // // Modifier: sortby - allows arrays of named arrays to be sorted by a given field // function smarty_modifier_sortby($arrData, $sortfields) { array_sort_by_fields($arrData, $sortfields); return $arrData; } // $smarty->register_modifier( "sortby", "smarty_modifier_sortby" );