community! My problem is that I must order a linked list in such a way that a new one is not created, but the same one is returned. For example, if I have: Head --> [8] --> [15] --> [1] should I return Head --> [1] --> [8] --> [15] My code right now, probably my code is awful and incorrect, but I'm new and I couldn't find the answer. Thanks for your time!
LinkedList.prototype.orderList = function() {
//temporary node to swap the element
let current = this.head;
if (LinkedList.value === null) return "Empty";
if (LinkedList.next.value === null) return "Orderer list"
while (this.head.next.value !== null) {
for (let i; i < LinkedList.length; i++)
if (LinkedList.head.value > LinkedList.head.next.value) {
current = LinkedList.head;
} else if (linkedList.LinkedList.head.next.value)
current = linkedList.head;
}
};