A linked list implementation in PHP. This linked list will maintain an ordered list of nodes from smallest to greatest. Inserting a new node will place it in the correct position, so the list should never need to be reordered.
It is considered a "stable order" as new nodes that are added, are placed after nodes with the same value.
Additionally, the linked list can also be reversed using $list->reverse();
.
php index.php
1, 1, 2, 2, 2, 3, 5, 7, 8, 9
9, 8, 7, 5, 3, 2, 2, 2, 1, 1