{"id":20506,"date":"2020-12-13T19:18:18","date_gmt":"2020-12-14T03:18:18","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=20506"},"modified":"2023-12-01T04:05:52","modified_gmt":"2023-12-01T12:05:52","slug":"python-quick-sort","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/","title":{"rendered":"How to Code a Python QuickSort"},"content":{"rendered":"\n<p><em>A Python QuickSort selects a pivot element and splits the elements of an <\/em><em>array<\/em><em> into two new <\/em><em>array<\/em><em>s. Numbers higher than the pivot go into one <\/em><em>array<\/em><em>; numbers lower than the pivot go into another. Each <\/em><em>array<\/em><em> is sorted and then all the <\/em><em>array<\/em><em>s are merged into one.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Code a Python QuickSort<\/h2>\n\n\n\n<p>There are plenty of sorting algorithms you can use to sort a list in programming. There\u2019s <a href=\"https:\/\/careerkarma.com\/blog\/python-insertion-sort\/\">Python <\/a><a href=\"https:\/\/careerkarma.com\/blog\/python-insertion-sort\/\">insertion sorts<\/a>, <a href=\"https:\/\/careerkarma.com\/blog\/python-bubble-sort-a-how-to-guide\/\">bubble sorts<\/a>, and more. QuickSort are one of the most common types of sorts.<\/p>\n\n\n\n<p>In this guide, we\u2019re going to talk about what QuickSorts are and how they work. We\u2019ll walk through an example of a Python QuickSort so you can learn how to implement one.<\/p>\n\n\n\n<p>Without further ado, let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Python QuickSort?<\/h2>\n\n\n\n<p>A Python QuickSort algorithm divides an array into sub arrays. This algorithm calls these sub arrays recursively to sort each element in the list. The contents of a sub array are determined by a pivot element that is not moved into a new sub array.<\/p>\n\n\n\n<p>The QuickSort algorithm divides-and-conquers. This means that the task of sorting a list is broken down into several subtasks. At the end of the sort, the results of these subtasks come together to return a sorted list.<\/p>\n\n\n\n<p>In a QuickSort, the subtask is setting a pivot for each sub list and ordering elements based on their value relative to the pivot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When Should I Use a Python QuickSort?<\/h2>\n\n\n\n<p>A QuickSort is useful when time complexity matters. This is because QuickSort use less memory space than other algorithms, which gives them an efficiency boost.<\/p>\n\n\n\n<p>You should only use a QuickSort if you are familiar with <a href=\"https:\/\/careerkarma.com\/blog\/python-recursion\/\">Python recursion<\/a>. This is because the QuickSort algorithm depends on recursive functions.<\/p>\n\n\n\n<p>A QuickSort is more efficient than a merge sort on smaller arrays. However, on larger data sets, an insertion sort or a merge sort may be faster.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Does a QuickSort Work?<\/h2>\n\n\n\n<p>A QuickSort picks an element to serve as a pivot. This can be any element in a list. For this tutorial, we\u2019re going to choose the last item in a list (3).<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>8<\/td><td>4<\/td><td>5<\/td><td>2<\/td><td>1<\/td><td><strong>3<\/strong><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>A QuickSort compares the value of pivot to every number when we loop through the items in the list. If an item is greater than the pivot number, we move the number after the pivot; otherwise, we move the number before the pivot:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>2<\/td><td>1<\/td><td><strong>3<\/strong><\/td><td>8<\/td><td>5<\/td><td>4<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>The value 3 has moved down our list. All the items less than 3 moved to its left; all the values greater than three moved to its right.<\/p>\n\n\n\n<p>Our <a href=\"https:\/\/careerkarma.com\/blog\/python-array\/\">Python array<\/a> is split into two halves: items greater than the pivot and items less than a pivot.<\/p>\n\n\n\n<p>Once this process has started, a new pivot begins on each of the two halves. This pivot begins separately and uses the same algorithm as above. First, we will set a pivot value which is equal to the last value in each list:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>Pivot One<\/strong><\/td><td><br><\/td><td><br><\/td><td><strong>Pivot Two<\/strong><\/td><td><br><\/td><td><br><\/td><\/tr><tr><td>2<\/td><td><strong>1<\/strong><\/td><td><br><\/td><td>8<\/td><td>5<\/td><td><strong>4<\/strong><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Next, we will move all the values greater than a pivot to the right of the pivot. We move all values less than the pivot to the left.<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>Pivot One<\/strong><\/td><td><br><\/td><td><br><\/td><td><strong>Pivot Two<\/strong><\/td><td><br><\/td><td><br><\/td><\/tr><tr><td><strong>1<\/strong><\/td><td>2<\/td><td><br><\/td><td><strong>4<\/strong><\/td><td>8<\/td><td><strong>5<\/strong><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>This process continues until we sort our list:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>First Time<\/strong><\/td><td>1<\/td><td><strong>2<\/strong><\/td><td><br><\/td><td>4<\/td><td>8<\/td><td>5<\/td><\/tr><tr><td><strong>Second Time<\/strong><\/td><td><br><\/td><td><strong>1<\/strong><\/td><td><br><\/td><td><br><\/td><td>8<\/td><td><strong>5<\/strong><\/td><\/tr><tr><td><br><\/td><td><br><\/td><td><br><\/td><td><br><\/td><td><br><\/td><td><strong>5<\/strong><\/td><td>87t?\/<\/td><\/tr><tr><td><strong>Third Time<\/strong><\/td><td><br><\/td><td><br><\/td><td><br><\/td><td><br><\/td><td><br><\/td><td>8<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Our final array looks like this:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><td>5<\/td><td>8<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\">Python QuickSort Example<\/h2>\n\n\n\n<p>The QuickSort needs two functions: a pivot function and a QuickSort function.<\/p>\n\n\n\n<p>Let\u2019s start with the partition function. This will partition, or prepare, the array based on the value of the pivot element.<\/p>\n\n\n\n<p>Our partition function will:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Select the pivot element<\/li><li>Move all items greater than the pivot to the right of the pivot<\/li><li>Move all items less than the pivot to the left of the pivot<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">QuickSort Python Program<\/h3>\n\n\n\n<p>Let\u2019s write a program which implements this algorithm:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def prepare(numbers, low, high):\n\tpivot = numbers[high]\n\titem = low - 1\n\n\tfor i in range(low, high):\n\t\tif numbers[i] &lt;= pivot:\n\t\t\titem = item + 1\n\t\t\t(numbers[item], numbers[i]) = (numbers[i], numbers[item])\n\n\t(numbers[item + 1], numbers[high]) = (numbers[high], numbers[item + 1])\n\n\treturn item + 1<\/pre><\/div>\n\n\n\n<p>First, we select a pivot element. This is equal to the highest number in our list.<\/p>\n\n\n\n<p>Next, we loop through all the items in the list using a <a href=\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\">Python for loop<\/a>. If a number is less than or equal to the pivot, it is moved to the left of the pivot. Otherwise, it goes to the right of the pivot.<\/p>\n\n\n\n<p>Our <a href=\"https:\/\/careerkarma.com\/blog\/python-functions\/\">Python function<\/a> returns the new high value. The new high value is equal to item + 1.<\/p>\n\n\n\n<p>Next, we\u2019ve got to run our algorithm. We can do this by writing a separate function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def quick_sort(numbers, low, high):\n\tif low &lt; high:\n\t\tpivot = prepare(numbers, low, high)\n\n\t\tquick_sort(numbers, low, pivot - 1)\n\n\t\tquick_sort(numbers, pivot + 1, high)<\/pre><\/div>\n\n\n\n<p>This function checks to see whether the value of \u201clow\u201d is less than the value of \u201chigh\u201d. If it is, our sort can continue. Otherwise, our sort stops. If our sort stops, it means we have sorted the list.<\/p>\n\n\n\n<p>Next, our function calls the <em>prepare()<\/em> method. This identifies a pointer for the pivot and moves items to their correct place.<\/p>\n\n\n\n<p>Our function then calls the <em>quick_sort()<\/em> method twice. The first time, we run the QuickSort on the elements to the left of the pivot. The second time, we run the QuickSort on the elements to the right of the pivot. Hence, our function is recursive because it calls itself.<\/p>\n\n\n\n<p>This continues until every item in the list is sorted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Writing a Main Method<\/h3>\n\n\n\n<p>Let\u2019s write a main program that defines a list to sort:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>values = [8, 4, 5, 2, 1, 3]\ntotal_values = len(values)\n\nquick_sort(values, 0, total_values - 1)\n\nprint(values)<\/pre><\/div>\n\n\n\n<p>First, we specify a list of values to sort. We use the <a href=\"https:\/\/careerkarma.com\/blog\/python-len\/\">Python len()<\/a> method to calculate the length of our list of values. Next, we call the <em>quick_sort()<\/em> method.<\/p>\n\n\n\n<p>We pass \u201cvalues\u201d as the numbers that we want to sort. We then pass 0 as the low number. The length of \u201cvalues\u201d minus 1 is the high value we specify. The high value is the length of values minus 1 because the first item in a list has the index number 0.<\/p>\n\n\n\n<p>Let\u2019s try to run our program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[1, 2, 3, 4, 5, 8]<\/pre><\/div>\n\n\n\n<p>Our code returns a sorted list! We did it. Give yourself a pat on the back. QuickSort are not easy to understand or implement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Complexity Overview<\/h2>\n\n\n\n<p>On average, this algorithm will perform at O(n* log n). This happens when the pivot element is not the greatest or smallest element and when the pivot element is not near the middle element.<\/p>\n\n\n\n<p>The QuickSort has the worst case complexity of O(n2). This occurs when the element selected as a pivot is either the greatest or smallest element. If this is the case, the pivot element will always be at the end of a sorted array. This will create a number of unnecessary sub arrays.<\/p>\n\n\n\n<p>The best case complexity for this algorithm is O(n* log n). This happens when the pivot element is either equal to the middle element or near the middle element.<\/p>\n\n\n\n<p>To learn more about algorithm complexity, check out our guide to <a href=\"https:\/\/careerkarma.com\/blog\/big-o-notation-time\/\">Big O Notation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Python QuickSorts use recursion to break down a list into smaller lists which are then sorted. Each list is sorted around a pivot element. Elements greater than the pivot are moved to its right; smaller elements are moved to the left of the pivot.<\/p>\n\n\n\n<p>For guidance on top Python learning resources, online courses, and books, read our comprehensive <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"A Python QuickSort selects a pivot element and splits the elements of an array into two new arrays. Numbers higher than the pivot go into one array; numbers lower than the pivot go into another. Each array is sorted and then all the arrays are merged into one. How to Code a Python QuickSort There&hellip;","protected":false},"author":240,"featured_media":3435,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-20506","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Code a Python QuickSort | Career Karma<\/title>\n<meta name=\"description\" content=\"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Code a Python QuickSort\" \/>\n<meta property=\"og:description\" content=\"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-14T03:18:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"797\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Code a Python QuickSort\",\"datePublished\":\"2020-12-14T03:18:18+00:00\",\"dateModified\":\"2023-12-01T12:05:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\"},\"wordCount\":1176,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\",\"name\":\"How to Code a Python QuickSort | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg\",\"datePublished\":\"2020-12-14T03:18:18+00:00\",\"dateModified\":\"2023-12-01T12:05:52+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg\",\"width\":1200,\"height\":797},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Code a Python QuickSort\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Code a Python QuickSort | Career Karma","description":"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/","og_locale":"en_US","og_type":"article","og_title":"How to Code a Python QuickSort","og_description":"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.","og_url":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-14T03:18:18+00:00","article_modified_time":"2023-12-01T12:05:52+00:00","og_image":[{"width":1200,"height":797,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Code a Python QuickSort","datePublished":"2020-12-14T03:18:18+00:00","dateModified":"2023-12-01T12:05:52+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/"},"wordCount":1176,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-quick-sort\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/","url":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/","name":"How to Code a Python QuickSort | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg","datePublished":"2020-12-14T03:18:18+00:00","dateModified":"2023-12-01T12:05:52+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"A quicksort selects a pivot element and sorts an array around that element. On Career Karma, learn how to code a Python quicksort.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-quick-sort\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/06\/farzad-nazifi-p-xSl33Wxyc-unsplash.jpg","width":1200,"height":797},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-quick-sort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"How to Code a Python QuickSort"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=20506"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20506\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/3435"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=20506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=20506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=20506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}