PHP - Sorting Indexed Arrays with sort() and rsort()

Introduction

sort() sorts the values of the array in ascending order: alphabetically for letters, numerically for numbers, letters before numbers.

rsort() sorts the values in descending order.

The function returns true if it managed to sort the array or false if there was a problem.

Demo

<?php

$authors = array("A","B","C","D");

sort($authors);/*from  www.  j  av  a2 s  .  com*/
print_r($authors);

rsort($authors);
print_r($authors);
?>

Result

Related Topic