<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Sort array alphabetically</title>
	<link>http://phpit.net/code/sort-array-alphabetically/</link>
	<description>PHPit has dozens of PHP articles, codesnippets and FAQ's.</description>
	<pubDate>Wed, 21 May 2008 02:16:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: BraveBrain</title>
		<link>http://phpit.net/code/sort-array-alphabetically/#comment-366</link>
		<pubDate>Fri, 06 Jan 2006 14:50:02 +0000</pubDate>
		<guid>http://phpit.net/code/sort-array-alphabetically/#comment-366</guid>
					<description>Seems I typed a lot of formatting spaces for nothing ;)

and
[1]=&#62; array(2){
should be
[1]=&#62; array(3){</description>
		<content:encoded><![CDATA[<p>Seems I typed a lot of formatting spaces for nothing ;)</p>
<p>and<br />
[1]=&gt; array(2){<br />
should be<br />
[1]=&gt; array(3){
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: BraveBrain</title>
		<link>http://phpit.net/code/sort-array-alphabetically/#comment-365</link>
		<pubDate>Fri, 06 Jan 2006 14:47:53 +0000</pubDate>
		<guid>http://phpit.net/code/sort-array-alphabetically/#comment-365</guid>
					<description>Note that the above function is for sorting multidimensional arrays.
I.e. if you had the following code after the function

$feeds[0]["TITLE"] = "Superman";
$feeds[0]["RATING"] = 4;
$feeds[0]["STATUS"] = "Sold";
$feeds[1]["TITLE"] = "Addams Family";
$feeds[1]["RATING"] = 3;
$feeds[2]["TITLE"] = "Winnie the Pooh";
$feeds[2]["RATING"] = 5;
usort($feeds, "cmp");

Would sort alphabetically by title like this
array(3) {
  [0]=&#62; array(2) {
     [0] Addams Family
     [1] 3
   }
  [1]=&#62; array(2){
     [0] Superman
     [1] 5
     [2] Sold
   }
  [2]=&#62; array(2){
     [0] Winnie the Pooh
     [1] 4
   }
}

For regular arrays it would be better to use the built in sort() function.</description>
		<content:encoded><![CDATA[<p>Note that the above function is for sorting multidimensional arrays.<br />
I.e. if you had the following code after the function</p>
<p>$feeds[0][&#8221;TITLE&#8221;] = &#8220;Superman&#8221;;<br />
$feeds[0][&#8221;RATING&#8221;] = 4;<br />
$feeds[0][&#8221;STATUS&#8221;] = &#8220;Sold&#8221;;<br />
$feeds[1][&#8221;TITLE&#8221;] = &#8220;Addams Family&#8221;;<br />
$feeds[1][&#8221;RATING&#8221;] = 3;<br />
$feeds[2][&#8221;TITLE&#8221;] = &#8220;Winnie the Pooh&#8221;;<br />
$feeds[2][&#8221;RATING&#8221;] = 5;<br />
usort($feeds, &#8220;cmp&#8221;);</p>
<p>Would sort alphabetically by title like this<br />
array(3) {<br />
  [0]=&gt; array(2) {<br />
     [0] Addams Family<br />
     [1] 3<br />
   }<br />
  [1]=&gt; array(2){<br />
     [0] Superman<br />
     [1] 5<br />
     [2] Sold<br />
   }<br />
  [2]=&gt; array(2){<br />
     [0] Winnie the Pooh<br />
     [1] 4<br />
   }<br />
}</p>
<p>For regular arrays it would be better to use the built in sort() function.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
