0

So I have these nodes I'm trying to sort as such, but it's not working.

This is psudo code:

Node first = new Node(23); //previously construted node

```
put method(newNode) {
Node traverseInOrder = first;
while (newNode > traverseInOrder) {
If (traverseInOrder.successor != null) {
traverseInOrder = traverseInOrder.successor;
}
else
}
newNode.predecessor = traverseInOrder;
newNode.successor = traverseInOrder.successor;
traverseInOrder.successor.predecessor = newNode
traverseInOrder.successor = newNode;
}
```

That's my basic algorithm, but it's not working. Can anyone give me a description of an algorithm that will work?

Thanks!