Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- inputArray = [(1, 2), (2, 3), (1, 5), (5, 3), ( 4, 1), (1, 2), (5, 5), (3, 4)]
- print psort(inputArray)
- raw_input('Press <ENTER> to continue')
- def psort(array):
- array.sort()
- n = 0
- pyrArray = []
- index = 0
- while len(array) > 0:
- if n == 0:
- pyrArray.insert(index, array.pop(0))
- index += 1
- n = 1
- else:
- pyrArray.insert(len(pyrArray) - index, array.pop(0))
- n = 0
- pyrArray.reverse()
- return pyrArray
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement