There is a php documentation. To know how to use arrays read this.
http://www.w3schools.com/php/php_arrays.asp
then you need to read the php asort() function documentation
http://www.w3schools.com/php/func_array_asort.asp
use the google to find documentation likewise.
So you can do the...