<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sorting a Multi-Dimensional Array with PHP</title>
	<atom:link href="http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/</link>
	<description>crunchy nuggets, served semi-daily</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:05:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Syed Rakib Al Hasan</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4410</link>
		<dc:creator>Syed Rakib Al Hasan</dc:creator>
		<pubDate>Wed, 08 Feb 2012 22:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4410</guid>
		<description>i find this approach easier to the eye than the article&#039;s approach</description>
		<content:encoded><![CDATA[<p>i find this approach easier to the eye than the article&#8217;s approach</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4409</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Mon, 06 Feb 2012 05:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4409</guid>
		<description>Thankyou! Worked perfectly!</description>
		<content:encoded><![CDATA[<p>Thankyou! Worked perfectly!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stefano smania</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4408</link>
		<dc:creator>stefano smania</dc:creator>
		<pubDate>Fri, 03 Feb 2012 22:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4408</guid>
		<description>Thank you! You helped me.</description>
		<content:encoded><![CDATA[<p>Thank you! You helped me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4390</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Tue, 10 Jan 2012 14:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4390</guid>
		<description>Wow lots of jerks in the comments here. This saved me the headache of trying to write it myself so thanks! I had an array of objects though so I had to make a slight change to where the values located:
&lt;pre&gt;
function subval_sort($a,$subkey) {
	foreach($a as $k=&gt;$v) {
		$b[$k] = strtolower($v-&gt;$subkey);
	}
	asort($b);
	foreach($b as $key=&gt;$val) {
		$c[] = $a[$key];
	}
	return $c;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Wow lots of jerks in the comments here. This saved me the headache of trying to write it myself so thanks! I had an array of objects though so I had to make a slight change to where the values located:</p>
<pre>
function subval_sort($a,$subkey) {
	foreach($a as $k=&gt;$v) {
		$b[$k] = strtolower($v-&gt;$subkey);
	}
	asort($b);
	foreach($b as $key=&gt;$val) {
		$c[] = $a[$key];
	}
	return $c;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam S</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4370</link>
		<dc:creator>Adam S</dc:creator>
		<pubDate>Wed, 07 Dec 2011 23:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4370</guid>
		<description>In nearly 3 years, no one - including me - has ever noticed that! Good eye!</description>
		<content:encoded><![CDATA[<p>In nearly 3 years, no one &#8211; including me &#8211; has ever noticed that! Good eye!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4369</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 07 Dec 2011 21:56:13 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4369</guid>
		<description>Your function seems to have changed the Pumpkins song from &quot;Soma&quot; to &quot;Cherub Rock&quot;. Better start debugging ;-)</description>
		<content:encoded><![CDATA[<p>Your function seems to have changed the Pumpkins song from &#8220;Soma&#8221; to &#8220;Cherub Rock&#8221;. Better start debugging <img src='http://www.firsttube.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brooks</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4354</link>
		<dc:creator>Brooks</dc:creator>
		<pubDate>Thu, 10 Nov 2011 02:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4354</guid>
		<description>This just helped me tremendously... And as a fellow phish fan, I thank you.</description>
		<content:encoded><![CDATA[<p>This just helped me tremendously&#8230; And as a fellow phish fan, I thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hung Nguyen</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4353</link>
		<dc:creator>Hung Nguyen</dc:creator>
		<pubDate>Tue, 08 Nov 2011 18:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4353</guid>
		<description>Thanks Adam,
You&#039;re so great, your func help me alot.
Thanks again ^^</description>
		<content:encoded><![CDATA[<p>Thanks Adam,<br />
You&#8217;re so great, your func help me alot.<br />
Thanks again ^^</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IDW Design</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4334</link>
		<dc:creator>IDW Design</dc:creator>
		<pubDate>Wed, 28 Sep 2011 00:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4334</guid>
		<description>Thanks Adam, you just helped me out of a sticky situation right there!
Ioan</description>
		<content:encoded><![CDATA[<p>Thanks Adam, you just helped me out of a sticky situation right there!<br />
Ioan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erwin Nandpersad</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4331</link>
		<dc:creator>Erwin Nandpersad</dc:creator>
		<pubDate>Sat, 24 Sep 2011 14:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4331</guid>
		<description>Thanks, very usefull!!</description>
		<content:encoded><![CDATA[<p>Thanks, very usefull!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Wadsworth</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4330</link>
		<dc:creator>Jon Wadsworth</dc:creator>
		<pubDate>Fri, 23 Sep 2011 22:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4330</guid>
		<description>Great example. I&#039;m glad there&#039;s others out there that are willing to post examples of simple code so others can easily port it to their project. Keep up the good work.</description>
		<content:encoded><![CDATA[<p>Great example. I&#8217;m glad there&#8217;s others out there that are willing to post examples of simple code so others can easily port it to their project. Keep up the good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4317</link>
		<dc:creator>Hans</dc:creator>
		<pubDate>Tue, 02 Aug 2011 22:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4317</guid>
		<description>Magic.  Worked beautifully - super simple, fast and easy.

Thanks for sharing.</description>
		<content:encoded><![CDATA[<p>Magic.  Worked beautifully &#8211; super simple, fast and easy.</p>
<p>Thanks for sharing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcos</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4316</link>
		<dc:creator>Marcos</dc:creator>
		<pubDate>Sat, 30 Jul 2011 19:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4316</guid>
		<description>Works very well for me. Now I can sort using different index. Thanks!</description>
		<content:encoded><![CDATA[<p>Works very well for me. Now I can sort using different index. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mad Rog</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4315</link>
		<dc:creator>Mad Rog</dc:creator>
		<pubDate>Fri, 29 Jul 2011 10:27:13 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4315</guid>
		<description>Very interesting, time saving and useful.

Thanks!

I added a few bits of the code together to allow for variables called the same name and sorting via asc or desc.

function subval_sort( $a, $subkey, $order) {
	foreach( $a as $k=&gt;$v )
		$b[$k] = strtolower( $v[$subkey] );
		if( $order === &#039;desc&#039; )
			arsort( $b );
		else
			asort( $b );
		foreach( $b as $k=&gt;$v )
		$c[] = $a[$k];
		return $c;
}

$albums = subval_sort($albums,&#039;name&#039;, &#039;asc&#039;);</description>
		<content:encoded><![CDATA[<p>Very interesting, time saving and useful.</p>
<p>Thanks!</p>
<p>I added a few bits of the code together to allow for variables called the same name and sorting via asc or desc.</p>
<p>function subval_sort( $a, $subkey, $order) {<br />
	foreach( $a as $k=&gt;$v )<br />
		$b[$k] = strtolower( $v[$subkey] );<br />
		if( $order === &#8216;desc&#8217; )<br />
			arsort( $b );<br />
		else<br />
			asort( $b );<br />
		foreach( $b as $k=&gt;$v )<br />
		$c[] = $a[$k];<br />
		return $c;<br />
}</p>
<p>$albums = subval_sort($albums,&#8217;name&#8217;, &#8216;asc&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Ecklund</title>
		<link>http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/comment-page-1/#comment-4310</link>
		<dc:creator>Michael Ecklund</dc:creator>
		<pubDate>Fri, 15 Jul 2011 18:34:09 +0000</pubDate>
		<guid isPermaLink="false">http://firsttubecom/?p=1044#comment-4310</guid>
		<description>Hello, first of all thank you for your wonderful post.

Secondly, I was wondering if it would be possible to take your function a little further...

I was looking to sort an array subkey by the order of another array. I have a user generated playlist, then all the songs are gathered. Then I need the gathered songs to be sorted by their trackName and match the order of the song titles the user entered in the Playlist Array.

I have made a post on Stack Overflow, regarding this possibility but I figured i&#039;d make a post on here as well since you are indeed the original author of this wonderful function.

If you&#039;re curious the link to the post on Stack Overflow is located here:
http://stackoverflow.com/questions/6711548/sort-array-subkey-based-on-another-arrays-order

Otherwise, I would love to hear a response from you... :)

Thanks!

-Michael Ecklund</description>
		<content:encoded><![CDATA[<p>Hello, first of all thank you for your wonderful post.</p>
<p>Secondly, I was wondering if it would be possible to take your function a little further&#8230;</p>
<p>I was looking to sort an array subkey by the order of another array. I have a user generated playlist, then all the songs are gathered. Then I need the gathered songs to be sorted by their trackName and match the order of the song titles the user entered in the Playlist Array.</p>
<p>I have made a post on Stack Overflow, regarding this possibility but I figured i&#8217;d make a post on here as well since you are indeed the original author of this wonderful function.</p>
<p>If you&#8217;re curious the link to the post on Stack Overflow is located here:<br />
<a href="http://stackoverflow.com/questions/6711548/sort-array-subkey-based-on-another-arrays-order" rel="nofollow">http://stackoverflow.com/questions/6711548/sort-array-subkey-based-on-another-arrays-order</a></p>
<p>Otherwise, I would love to hear a response from you&#8230; <img src='http://www.firsttube.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks!</p>
<p>-Michael Ecklund</p>
]]></content:encoded>
	</item>
</channel>
</rss>

