Skip to content
Snippets Groups Projects
Commit 766d5dbb authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-6427-ebremner-preserve-weight-ordering' into '1.1.x'

ISTWCMS-6427: adding function to sort array by weight

See merge request !368
parents 00f7fdcb a0fdfe1d
No related branches found
No related tags found
1 merge request!368ISTWCMS-6427: adding function to sort array by weight
......@@ -219,3 +219,22 @@ function uw_fix_tags_array(array $tags, string $content_type): array {
return $tags;
}
/**
* Function to sort array by weight.
*
* @param array $arr
* The array to be sorted.
*
* @return array
* The sorted array.
*/
function uw_sort_array_by_weight(array $arr): array {
// Sort the array by weight.
usort($arr, function ($a, $b) {
return $a['weight'] > $b['weight'];
});
return $arr;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment