#Quicksort program - Using Filter to (potentially) make it parallel. #Note that the recursive calls to quicksort that produce sorted1 and #sorted2 could also be run in parallel # # Jay Summet # CS 1301 - Georgia Institute of Technology from random import randrange def quicksort( aList ): if ( len(aList) < 2): return( aList ) pivotIndex = randrange(0, len( aList) ) pivot = aList[ pivotIndex] del aList[pivotIndex] lessThanPivot = filter( lambda x: x < pivot , aList) eqGreater = filter( lambda y: y >= pivot, aList) sorted1 = quicksort( lessThanPivot) sorted2 = quicksort( eqGreater) result = sorted1 + [ pivot ] + sorted2 return( result) myList = [ 5, 10, 3, 11, 3, 8, 16, -2] result = quicksort( myList) print result