What are best practices for ordering entries in a guestbook without using MySQL?

When ordering entries in a guestbook without using MySQL, you can use PHP to read the entries from a text file, store them in an array, sort the array based on a specific criteria (such as timestamp or name), and then display the sorted entries on the page.

<?php
// Read entries from the guestbook text file
$entries = file('guestbook.txt', FILE_IGNORE_NEW_LINES);

// Sort the entries based on timestamp
usort($entries, function($a, $b) {
    $a_timestamp = strtotime(explode('|', $a)[0]);
    $b_timestamp = strtotime(explode('|', $b)[0]);
    return $a_timestamp - $b_timestamp;
});

// Display the sorted entries
foreach ($entries as $entry) {
    list($timestamp, $name, $message) = explode('|', $entry);
    echo "<p>$name - $timestamp<br>$message</p>";
}
?>