It sort the result-set by a specified column and by default it sort in ascending order
SQL ORDER BY Syntax
SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DES ;
MySQL Table – users
+—-+——+
| id | name |
+—-+——+
| 1 | PHP |
| 2 | JS |
| 3 | HTML |
| 4 | PHP |
+—-+——+
Example
mysql> select * from users ORDER BY name ;
+—-+——+
| id | name |
+—-+——+
| 3 | HTML |
| 2 | JS |
| 1 | PHP |
| 4 | PHP |
+—-+——+
4 rows in set (0.02 sec)
mysql> select * from users ORDER BY name DESC;
+—-+——+
| id | name |
+—-+——+
| 1 | PHP |
| 4 | PHP |
| 2 | JS |
| 3 | HTML |
+—-+——+
4 rows in set (0.00 sec)