atitthaker Posted August 17, 2006 Share Posted August 17, 2006 I am getting unexpected result while sorting with arsort() and asort()...The code and given output are as given below...----------------------------print("</br>Revese sorting array by arsort </br>");$myArray=array("apple","banana","grapes","lotus","red","green");arsort($myArray,SORT_STRING);print_r($myArray);print("</br>Sorting array by asort </br>");$myArray=array("apple","banana","grapes","lotus","red","green");asort($myArray,SORT_STRING);print_r($myArray);------------------------------The output I get is:------------------------------Revese sorting array by arsort Array( [4] => red [5] => green [3] => lotus [2] => grapes [1] => banana [0] => apple)Sorting array by asort Array( [1] => banana [0] => apple [2] => grapes [3] => lotus [5] => green [4] => red)What I mean is it is not changing the order of 'banana' and 'apple' why so?Even the order it is generating is not understanable. If someone can make it clear please help.... Link to comment https://forums.phpfreaks.com/topic/17832-problem-with-arsort-and-asort/ Share on other sites More sharing options...
Ifa Posted August 17, 2006 Share Posted August 17, 2006 Try without the SORT_STRING Link to comment https://forums.phpfreaks.com/topic/17832-problem-with-arsort-and-asort/#findComment-76136 Share on other sites More sharing options...
atitthaker Posted August 17, 2006 Author Share Posted August 17, 2006 I don't know but it started working fine suddenly... I can't believe this thing.Thanks anyway Link to comment https://forums.phpfreaks.com/topic/17832-problem-with-arsort-and-asort/#findComment-76138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.