sort associative array by key
<p>I want to sort associative array by key. I use ksort funtion but it returning 1 instead of array.Below is my code.</p>

<pre><code>$states=array( "DD"=&gt;"Daman and Diu", "LD"=&gt;"Lakshdweep", "DN"=&gt;"Dadra
and nagar haveli", "AN"=&gt;"Andaman and Nicobar island", "SK"=&gt;"Sikkim",
"MZ"=&gt;"Mizoram", "GA"=&gt;"Goa", "PY"=&gt;"Puduchery", "CH"=&gt;"Chandigarh",
"ML"=&gt;"Meghalaya", "AR"=&gt;"Arunachal Pradesh", "TR"=&gt;"Tripura",
"HP"=&gt;"Himanchal Pradesh", "NL"=&gt;"Nagaland", "PB"=&gt;"Punjab",
"CG"=&gt;"Chattisgarh", "JK"=&gt;"Jammu and Kashmir", "UA"=&gt;"Uttrakhand",
"HR"=&gt;"Haryana", "JH"=&gt;"Jharkhand", "KL"=&gt;"Kerela", "MN"=&gt;"Manipur" ,
"AS"=&gt;"Assam", "RJ"=&gt;"Rajasthan", "MP"=&gt;"Madhya Pradesh",
"KA"=&gt;"Karnataka", "BR"=&gt;"Bihar", "OR"=&gt;"Orissa", "GJ"=&gt;"Gujrat",
"AP"=&gt;"Andhra Pradesh", "TN"=&gt;"TamilNadu", "DL"=&gt;"Delhi",
"MH"=&gt;"Maharastra", "WB"=&gt;"WestBengal", "UP"=&gt;"UttarPradesh",
); 


 $states = ksort($states);
 print_r($states);
</code></pre>

<p>Output i am getting is: <code>1</code></p>

<p>I want array instead of 1.</p>
