Contact Us || Privacy Policy || About Us |
|
Sorting ArraysSorting Arrays sorted in alphabetical or numerical order, in descending or ascending order. There are following Sort Functions Arrays that is.
1) sort() function in PHPThis function is used to sorting the elements of the indexed array in ascending order . Example 1 :-Output Android Java PHP Example 2 :-Output 1 2 3 5 10 2) rsort() function in PHPThis function is used to sorting the elements of the indexed array in decending order . Example 1 :-Output PHP Java Android Example 2 :-Output 22 11 6 4 2 3) asort() function in PHPAccording to the value, sorts an associative array in ascending order. Example 1 :-Output Key=Peter, Value=10 Key=Joe, Value=20 Key=Ben, Value=40 4) ksort() function in PHPAccording to the key, sorts an associative array in ascending order. Example :-Output Key=Ben, Value=10 Key=Joe, Value=43 Key=Peter, Value=20 5) krsort()According to the key , sorts an associative array in descending order. Example :-Output Key=Peter, Value=30 Key=Joe, Value=53 Key=Ben, Value=40 |