Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class algorithms:
- def bubblesort(self, li, *,reversed=False):
- for i in range(len(li)):
- for j in range(i+1,len(li)):
- if (li[i] < li[j] if reversed else li[i] > li[j]):
- li[i], li[j] = li[j], li[i]
- class Solution(algorithms):
- pass
- Sol1 = Solution()
- unsortedarr = [3, 1, 2, 4, 5, 6, 7]
- unsortedrev = [3, 1, 2, 4, 5, 6, 7]
- print("WIth no reverse: ")
- Sol1.bubblesort(unsortedarr)
- print(unsortedarr)
- print("WIth Reversed:")
- Sol1.bubblesort(unsortedrev, reversed=True)
- print(unsortedrev)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement