Due to the enormous and ever repeating amount of "How do I sort my unique snowflake of an array?" questions, this is a reference collection of basic sorting methods in PHP. Please close any question which does not markedly differ as a duplicate of this one.
How do I sort an array in PHP?
How do I sort a complex array in PHP?
How do I sort an array of objects in PHP?
For the practical answer using PHP's existing functions see 1., for the academic in-detail answer on sorting algorithms (which PHP's functions implement and which you may need for really, really complex cases), see 2.