How can ENUM columns be utilized for sorting mysql_query output in PHP?

When sorting mysql_query output in PHP, ENUM columns can be utilized by specifying the ENUM values in the ORDER BY clause. This allows for sorting based on the predefined values of the ENUM column.

// Connect to the database
$connection = mysqli_connect('localhost', 'username', 'password', 'database');

// Query to fetch data from the database and sort by ENUM column
$query = "SELECT * FROM table_name ORDER BY enum_column ASC";
$result = mysqli_query($connection, $query);

// Fetch and display the sorted data
while ($row = mysqli_fetch_array($result)) {
    echo $row['enum_column'] . "<br>";
}

// Close the connection
mysqli_close($connection);