Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

de #26

Open
mehdius708 opened this issue Sep 17, 2020 · 0 comments
Open

de #26

mehdius708 opened this issue Sep 17, 2020 · 0 comments

Comments

@mehdius708
Copy link

mehdius708 commented Sep 17, 2020

Hi,

I am starting to get in touch with linked lists and other data structures types,
A part ";" errors I found in the code, the problem is in the newlist [type List] there will be references of objects "nodes" of previous linked lists and not the "data", so I propose to you to use get_data() function when appending data to the temporary list instead of node object references which will simplify the code as below:

def sort_list(self, reverse_list = True):
if self.size > 1:
temp_list = []
current = self.root

            temp_list.append(current.get_data())
            while current.has_next_node():
                current = current.get_next()
                temp_list.append(current.get_data())
            
            temp_list = sorted(temp_list,  reverse = reverse_list)
            
            sorted_Linked_List = LinkedList()
            for element in temp_list:
                sorted_Linked_List.add_node(element)
            return sorted_Linked_List
        return self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant