Let us initialize first and last nodes of three linked lists 1 ) Linked list of values smaller than x . 2 ) Linked list of values equal to x . 3 ) Linked list of values greater than x .
smallerHead = None NEW_LINE smallerLast = None NEW_LINE greaterLast = None NEW_LINE greaterHead = None NEW_LINE equalHead = None NEW_LINE equalLast = None NEW_LINE