{"id":1281,"date":"2024-04-23T07:55:56","date_gmt":"2024-04-22T22:55:56","guid":{"rendered":"http:\/\/inwelly.com\/?p=1281"},"modified":"2024-04-23T07:55:56","modified_gmt":"2024-04-22T22:55:56","slug":"sort-an-array-of-associative-arrays-by-column-value-%eb%b0%b0%ec%97%b4-%ec%a0%95%eb%a0%ac-value-%ec%9d%b4%ec%9a%a9","status":"publish","type":"post","link":"https:\/\/inwelly.com\/?p=1281","title":{"rendered":"Sort an array of associative arrays by column value ( \ubc30\uc5f4 \uc815\ub82c &#8211; value \uc774\uc6a9 )"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$category = Array (&nbsp;<\/p>\n\n\n\n<p>[0] =&gt; Array ( [term_id] =&gt; 7 [name] =&gt; MY PROJECT [sort] =&gt; 2 )&nbsp;<\/p>\n\n\n\n<p>[1] =&gt; Array ( [term_id] =&gt; 9 [name] =&gt; YOUTUBE [sort] =&gt; 3 )&nbsp;<\/p>\n\n\n\n<p>[2] =&gt; Array ( [term_id] =&gt; 110 [name] =&gt; \uba38\ub9ac\uc18d\uc5d0 \ub123\uc5b4\uc57c \ud560\uae4c [sort] =&gt; 6 )&nbsp;<\/p>\n\n\n\n<p>[3] =&gt; Array ( [term_id] =&gt; 3 [name] =&gt; \uc77c\uc0c1 [sort] =&gt; 5 ) )<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>$sortArr = array();\nforeach ($category as $key => $row)\n{\n    $price&#91;$key] = $row&#91;\u2018sort\u2019];\n}\narray_multisort($sortArr, SORT_ASC, $category);\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>array_column()\u00a0instead ( as of PHP 5.5.x ) below.<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>$sortArr = array_column($category, 'sort');\n\narray_multisort($sortArr, SORT_ASC, $category);\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\/\/&#8212;- \uacb0\uacfc(RESULT)&#8212;-<br>$category = Array (\u00a0<\/p>\n\n\n\n<p>[0] =&gt; Array ( [term_id] =&gt; 7 [name] =&gt; MY PROJECT [sort] =&gt; 2 )&nbsp;<\/p>\n\n\n\n<p>[1] =&gt; Array ( [term_id] =&gt; 9 [name] =&gt; YOUTUBE [sort] =&gt; 3 )&nbsp;<\/p>\n\n\n\n<p>[2] =&gt; Array ( [term_id] =&gt; 3&nbsp; [name] =&gt; \uc77c\uc0c1 [sort] =&gt; 5 )&nbsp;<\/p>\n\n\n\n<p>[3] =&gt; Array ( [term_id] =&gt; 110 [name] =&gt; \uba38\ub9ac\uc18d\uc5d0 \ub123\uc5b4\uc57c \ud560\uae4c [sort] =&gt; 6 ) )<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>$category = Array (&nbsp; [0] =&gt; Array ( [term_id] =&gt; 7 [name] =&gt; MY PROJECT [sort] =&gt; 2 )&nbsp; [1] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1281"}],"version-history":[{"count":1,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1281\/revisions"}],"predecessor-version":[{"id":1282,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/1281\/revisions\/1282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/media\/1251"}],"wp:attachment":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}