Node partition(int x) {
        Node less = null;
        Node more = null;
        
        Node current = this;
        while(current != null) {
            if(current.data < x) {
                if(less != null) {
                    less.appendToTail(current.data);
                }
                else {
                    less = new Node(current.data);
                }
            }
            else {
                if(more != null) {
                    more.appendToTail(current.data);
                }
                else {
                    more = new Node(current.data);
                }
            }
            current = current.next;
        }
        
        less.appendToTail(more);
        return less;
    }