Skip to content

Commit

Permalink
Final change
Browse files Browse the repository at this point in the history
  • Loading branch information
AliHusseinAlmoussawi committed Nov 26, 2023
1 parent 45cdb8b commit 429b8c9
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,42 +109,38 @@ def createNestedTabs(Tabs):
# Sorting tabs according to titles
def sortTabs(Tabs):
if len(Tabs) > 1:
if len(Tabs) > 1:
mid = len(Tabs) // 2
left = Tabs[:mid]
right = Tabs[mid:]
mid = len(Tabs) // 2
left = Tabs[:mid]
right = Tabs[mid:]

sortTabs(left)
sortTabs(right)
sortTabs(left)
sortTabs(right)

i = j = k = 0
i = j = k = 0

while i < len(left) and j < len(right):
if left[i]['Title'] < right[j]['Title']:
Tabs[k] = left[i]
i += 1

else:
Tabs[k] = right[j]
j += 1

k += 1

while i < len(left):
while i < len(left) and j < len(right):
if left[i]['Title'] < right[j]['Title']:
Tabs[k] = left[i]
i += 1
k += 1

while j < len(right):
else:
Tabs[k] = right[j]
j += 1
k += 1

print("Tabs sorted successfully")
else:
print("There should be at least two tabs to sort.")
printTitles(Tabs)
k += 1

while i < len(left):
Tabs[k] = left[i]
i += 1
k += 1

while j < len(right):
Tabs[k] = right[j]
j += 1
k += 1

else:
return

# Sorting nested tabs
def sortNestedTabs(Tabs):
Expand Down

0 comments on commit 429b8c9

Please sign in to comment.