de
mehdius708 opened this issue · 0 comments
mehdius708 commented
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 which will simplify the code as:
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