{article Examples__Python 3.4 }{title} {text} {/article}

def quickSort(list):
if not list:
return []
else:
pivot = list[0]
less = [x for x in list if x < pivot]
more = [x for x in list[1:] if x >= pivot]
return quickSort(less) + [pivot] + quickSort(more)

"Enter example below in shel"
a = [54,-26,100,17,77,1,999,55,20]
quickSort(a)

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def quickSort(list):
if not list:
return []
else:
pivot = list[0]
less = [x for x in list if x < pivot]
more = [x for x in list[1:] if x >= pivot]
return quickSort(less) + [pivot] + quickSort(more)

>>> a = [54,-26,100,17,77,1,999,55,20]
>>> quickSort(a)
[-26, 1, 17, 20, 54, 55, 77, 100, 999]
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}