php - Sort a 2d array by a column value - Stack Overflow

PHOTO EMBED

Sat Nov 02 2024 22:34:44 GMT+0000 (Coordinated Universal Time)

Saved by @xsirlalo #php

$new = [
    [
        'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
        'title' => 'Flower',
        'order' => 3,
    ],
    [
        'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
        'title' => 'Free',
        'order' => 2,
    ],
    [
        'hashtag' => 'e7d31fc0602fb2ede144d18cdffd816b',
        'title' => 'Ready',
        'order' => 1,
    ],
];
$keys = array_column($new, 'order');
array_multisort($keys, SORT_ASC, $new);
var_dump($new);
content_copyCOPY

https://stackoverflow.com/questions/2699086/sort-a-2d-array-by-a-column-value