Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # How this is going to work:
- # for each item in the list:
- # if the item is greater than the item to the right of it:
- # switch places between the two
- # start over; repeat
- # eventually it will be sorted.
- def qksort(data):
- iteration = 1
- while iteration < len(data):
- for key, value in enumerate(data):
- if key != len(data) - 1:
- if value > data[key + 1]:
- data[key], data[key + 1] = data[key + 1], data[key]
- iteration += 1
- return data
- example = [5,1,6,2,4,8,0]
- print qksort(example)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement