{"id":169381,"date":"2021-11-30T13:17:27","date_gmt":"2021-11-30T13:17:27","guid":{"rendered":"https:\/\/www.softwaretestinghelp.com\/?page_id=169381"},"modified":"2025-04-01T09:35:06","modified_gmt":"2025-04-01T09:35:06","slug":"python-sorting-methods","status":"publish","type":"page","link":"https:\/\/www.softwaretestinghelp.com\/python-sorting-methods\/","title":{"rendered":"Python Sort: Sorting Methods And Algorithms In Python"},"content":{"rendered":"<p><strong>Learn how to use the Python Sort function for sorting lists, arrays, dictionaries, etc using various sorting methods and algorithms in Python:<\/strong><\/p>\n<p>Sorting is a technique that is used for sorting the data in a sequence order either in ascending or descending order.<\/p>\n<p>Most of the time the data of the large projects is not arranged in the correct order and this creates problems while accessing and fetching the required data efficiently.<\/p>\n<p>Sorting techniques are used to resolve this problem. Python provides various sorting techniques <span style=\"text-decoration: underline;\"><strong>for example,<\/strong><\/span> Bubble sort, Insertion sort, Merge sort, Quicksort, etc.<\/p>\n<p>In this tutorial, we will understand how sorting works in Python by using various algorithms.<\/p>\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/python\/\">Take A Look At The Python Beginners Guide Here<\/a><\/strong><\/p>\n<p><strong><em> <\/em><\/strong><\/p>\n<h2>Python Sort<\/h2>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169520\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort-1.png\" alt=\"Python sort\" width=\"700\" height=\"394\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort-1.png 700w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort-1-300x169.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<h3>Syntax of Python Sort<\/h3>\n<p>To perform sorting, Python provides the built-in function i.e. the \u201c sort() \u201d function. It is used to sort the data elements of a list in ascending order or in descending order.<\/p>\n<p>Let&#8217;s understand this concept with an example.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Example 1:<\/strong><\/span><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\na = &#x5B; 3, 5, 2, 6, 7, 9, 8, 1, 4 ]\r\na.sort()\r\nprint( \u201c List in ascending order: \u201d, a )\r\n\r\n```\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_ascending_order-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-169414 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_ascending_order-1.png\" alt=\"list_ascending_order - Syntax\" width=\"642\" height=\"111\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_ascending_order-1.png 642w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_ascending_order-1-300x52.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/a><\/p>\n<p>In this example, the given unordered list is sorted into ascending order by using the \u201c sort( ) \u201d function.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Example 2:<\/strong><\/span><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\na = &#x5B; 3, 5, 2, 6, 7, 9, 8, 1, 4 ]\r\na.sort( reverse = True )\r\nprint( \u201c List in descending order: \u201d, a )\r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_in_descending_order-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169384\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_in_descending_order-1.png\" alt=\"list_in_descending_order\" width=\"657\" height=\"108\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_in_descending_order-1.png 657w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/list_in_descending_order-1-300x49.png 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/a><\/p>\n<p>In the above example, the given unordered list is sorted in the reverse order using the function \u201c sort( reverse = True ) \u201d.<\/p>\n<h3>Time Complexity of Sorting Algorithms<\/h3>\n<p>Time Complexity is the amount of time taken by the computer to run a particular algorithm. It has three types of time complexity cases.<\/p>\n<ul>\n<li><strong>Worst Case:<\/strong> Maximum time taken by the computer to run the program.<\/li>\n<li><strong>Average Case:<\/strong> Time taken between the minimum and maximum by the computer to run the program.<\/li>\n<li><strong>Best Case:<\/strong> Minimum time taken by the computer to run the program. It is the best case of time complexity.<\/li>\n<\/ul>\n<h3>Complexity Notations<\/h3>\n<p><strong>Big Oh Notation, O:<\/strong> Big oh notation is the official way to convey the upper bound of running time of the algorithms. It is used to measure the worst-case time complexity or we say the largest amount of time taken by the algorithm to complete.<\/p>\n<p><strong>Big omega Notation, <a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/09\/omega.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-189156\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/09\/omega.jpg\" alt=\"omega\" width=\"15\" height=\"15\" \/><\/a>: <\/strong>Big omega notation is the official way to convey the lowest bound of the running time of the algorithms. It is used to measure best-case time complexity or we say the excellent amount of time taken by the algorithm.<\/p>\n<p><strong>Theta Notation, <a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/09\/heta.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-189157\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/09\/heta.png\" alt=\"theta\" width=\"10\" height=\"18\" \/><\/a>: <\/strong>Theta notation is the official way to convey both bounds i.e. lower and upper of the time taken by the algorithm to complete.<\/p>\n<h2>Sorting Methods in Python<\/h2>\n<h3>Bubble Sort<\/h3>\n<p>Bubble sort is the simplest way to sort the data which uses the brute force technique. It will iterate to each data element and compare it with other elements to provide the user with the sorted data.<\/p>\n<p><strong>Let us take an example to understand this technique:<\/strong><\/p>\n<ul>\n<li>We are provided with an array having the elements \u201c 10, 40, 7, 3, 15 \u201d. Now, we need to arrange this array in an ascending order using the Bubble sort technique in Python.\n<ul>\n<li>The very first step is to arrange the array in the given order.<\/li>\n<li>In the \u201c Iteration 1 \u201d, we are comparing the first element of an array with the other elements one by one.<\/li>\n<li>The red arrows are describing the comparison of the first elements with the other elements of an array.<\/li>\n<li>If you notice \u201c 10 \u201d is smaller than \u201c 40 \u201d so, it remains at the same place but the next element \u201c 7 \u201d is smaller than \u201c 10 \u201d. Hence it gets replaced and comes to the first place.<\/li>\n<li>The above process will be performed again and again to sort the elements.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort.png\"><img decoding=\"async\" class=\"alignnone wp-image-169386 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort.png\" alt=\"Python sort - Iteration 1\" width=\"367\" height=\"462\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort.png 367w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Python-sort-238x300.png 238w\" sizes=\"(max-width: 367px) 100vw, 367px\" \/><\/a><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>In the \u201c Iteration 2 \u201d the second element is getting compared with the other elements of an array.<\/li>\n<li>If the compared element is small then, it will get replaced, otherwise it will remain at the same place.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_2.png\"><img decoding=\"async\" class=\"alignnone wp-image-169387 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_2.png\" alt=\"bubble_sort_ - Iteration 2\" width=\"369\" height=\"386\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_2.png 369w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_2-287x300.png 287w\" sizes=\"(max-width: 369px) 100vw, 369px\" \/><\/a><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>In \u201c Iteration 3 \u201c the third element is getting compared with the other elements of an array.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Syntax-of-Sort-in-Python.png\"><img decoding=\"async\" class=\"alignnone wp-image-169388 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Syntax-of-Sort-in-Python.png\" alt=\"Iteration 3\" width=\"369\" height=\"224\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Syntax-of-Sort-in-Python.png 369w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Syntax-of-Sort-in-Python-300x182.png 300w\" sizes=\"(max-width: 369px) 100vw, 369px\" \/><\/a><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>In the last \u201c Iteration 4 \u201c the second last element is getting compared with the other elements of an array.<\/li>\n<li>In this step the array is sorted in the ascending order.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169389\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_4.png\" alt=\"bubble_sort_4\" width=\"506\" height=\"191\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_4.png 506w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_4-300x113.png 300w\" sizes=\"(max-width: 506px) 100vw, 506px\" \/><\/a><\/p>\n<p><strong>Program for Bubble sort<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\ndef Bubble_Sort(unsorted_list):   \r\n\tfor i in range(0,len(unsorted_list)-1):  \r\n    \tfor j in range(len(unsorted_list)-1):  \r\n        \tif(unsorted_list&#x5B;j]&gt;unsorted_list&#x5B;j+1]):  \r\n            \ttemp_storage = unsorted_list&#x5B;j]  \r\n            \tunsorted_list&#x5B;j] = unsorted_list&#x5B;j+1]  \r\n            \tunsorted_list&#x5B;j+1] = temp_storage  \r\n\treturn unsorted_list  \r\n \t \r\nunsorted_list = &#x5B;5, 3, 8, 6, 7, 2]  \r\nprint(&quot;Unsorted List: &quot;, unsorted_list)  \r\nprint(&quot;Sorted List using Bubble Sort Technique: &quot;, Bubble_Sort(unsorted_list)) \r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_output.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169390\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_output.png\" alt=\"bubble_sort_output\" width=\"738\" height=\"115\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_output.png 738w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/bubble_sort_output-300x47.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/p>\n<p><strong>Time Complexity of Bubble sort<\/strong><\/p>\n<ul>\n<li><strong>Worst Case:<\/strong> The worst time complexity for bubble sort is O(<em>n<\/em><sup>2<\/sup>).<\/li>\n<li><strong>Average Case:<\/strong> The average time complexity for bubble sort is O(<em>n<\/em><sup>2<\/sup>).<\/li>\n<li><strong>Best Case:<\/strong> The best time complexity for bubble sort is O(n).<\/li>\n<\/ul>\n<p><strong>Advantages<\/strong><\/p>\n<ul>\n<li>It is mostly used and is easy to implement.<\/li>\n<li>We can swap the data elements without consumption of short-term storage.<\/li>\n<li>It requires less space.<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>It did not perform well while dealing with a large number of large data elements.<\/li>\n<li>It needs <em>n<\/em><sup>2<\/sup> steps for each \u201cn\u201d number of data elements to get sorted.<\/li>\n<li>It is not really good for real-world applications.<\/li>\n<\/ul>\n<h3>Insertion Sort<\/h3>\n<p>Insertion sort is an easy and simple sorting technique that works similar to sorting the playing cards. Insertion sort sorts the elements by comparing each element one by one with the other. The elements are picked and swapped with the other element if the element is greater or smaller than the other.<\/p>\n<p><strong>Let\u2019s take an example<\/strong><\/p>\n<ul>\n<li>We are provided with an array having the elements \u201c 100, 50, 30, 40, 10 \u201d.<\/li>\n<li>First, we arrange the array and start comparing it.<\/li>\n<li>In the first step \u201c 100 \u201d is compared with the second element \u201c 50 \u201d. \u201c 50 \u201d is swapped with \u201c 100 \u201d as it is greater.<\/li>\n<li>In the second step, again the second element \u201c 100 \u201d is compared with the third element \u201c 30 \u201d and gets swapped.<\/li>\n<li>Now, if you notice \u201c 30 \u201d comes to the first place because it is again smaller than \u201c 50 \u201d.<\/li>\n<li>The comparison will occur till the last element of an array and at the end, we will get the sorted data.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/insertion_sort_moqup.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169391\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/insertion_sort_moqup.png\" alt=\"insertion_sort_moqup\" width=\"374\" height=\"363\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/insertion_sort_moqup.png 374w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/insertion_sort_moqup-300x291.png 300w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/a><\/p>\n<p><strong>Program for Insertion sort<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\ndef InsertionSort(array):\r\n\tfor i in range(1, len(array)):\r\n \r\n    \tkey_value = array&#x5B;i]\r\n    \tj = i-1\r\n    \twhile j &gt;= 0 and key_value &lt; array&#x5B;j] :\r\n            \tarray&#x5B;j + 1] = array&#x5B;j]\r\n            \tj -= 1\r\n    \tarray&#x5B;j + 1] = key_value\r\n\r\narray = &#x5B;11, 10, 12, 4, 5]\r\nprint(&quot;The unsorted array: &quot;, array)\r\nInsertionSort(array)\r\nprint (&quot;The sorted array using the Insertion Sort: &quot;)\r\nfor i in range(len(array)):\r\n\tprint (array&#x5B;i])\r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array.png\"><img decoding=\"async\" class=\"alignnone wp-image-169392 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array.png\" alt=\"Program for Insertion Sort\" width=\"552\" height=\"240\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array.png 552w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array-300x130.png 300w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/a><\/p>\n<p><strong>Time Complexity of Insertion sort<\/strong><\/p>\n<ul>\n<li><strong>Worst Case:<\/strong> The worst time complexity for Insertion sort is O(<em>n<\/em><sup>2<\/sup>).<\/li>\n<li><strong>Average Case:<\/strong> The average time complexity for Insertion sort is O(<em>n<\/em><sup>2<\/sup>).<\/li>\n<li><strong>Best Case:<\/strong> The best time complexity for Insertion sort is O(n).<\/li>\n<\/ul>\n<p><strong>Advantages<\/strong><\/p>\n<ul>\n<li>It is simple and easy to implement.<\/li>\n<li>It performs well while dealing with a small number of data elements.<\/li>\n<li>It does not need more space for its implementation.<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>It is not helpful to sort a huge number of data elements.<\/li>\n<li>When compared to other sorting techniques it does not perform well.<\/li>\n<\/ul>\n<h3>Merge sort<\/h3>\n<p>This sorting method uses the divide and conquer method to sort the elements in a specific order. While sorting with the help of merge sort, the elements are divided into halves and then, they get sorted. After sorting all the halves, again the elements get joined to form a perfect order.<\/p>\n<p><strong>Let\u2019s take an example to understand this technique<\/strong><\/p>\n<ul>\n<li>We are provided with an array \u201c 7, 3, 40, 10, 20, 15, 6, 5 \u201d. The array contains 7 elements. If we divide it into half ( 0 + 7 \/ 2 = 3 ).<\/li>\n<li>In the second step, you will see that the elements are divided into two parts. Each having 4 elements in it.<\/li>\n<li>Further, the elements are again divided and have 2 elements each.<\/li>\n<li>This process will continue until only one element is present in an array. Refer to step no. 4 in the picture.<\/li>\n<li>Now, we will sort the elements and start joining them as we were divided.<\/li>\n<li>In step no. 5 if you notice 7 is greater than 3, so we will exchange them and join it in the next step and vice versa.<\/li>\n<li>At the end, you will notice that our array is getting sorted in ascending order.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/merger_sort.png\"><img decoding=\"async\" class=\"alignnone wp-image-169394 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/merger_sort.png\" alt=\"merger_sort\" width=\"531\" height=\"419\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/merger_sort.png 531w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/merger_sort-300x237.png 300w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/a><\/p>\n<p><strong>Program for Merge sort<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\ndef MergeSort(arr):\r\n\tif len(arr) &gt; 1:\r\n\r\n    \tmiddle = len(arr)\/\/2\r\n\r\n    \tL = arr&#x5B;:middle]\r\n    \tR = arr&#x5B;middle:]\r\n    \tMergeSort(L)\r\n    \tMergeSort(R)\r\n\r\n    \ti = j = k = 0\r\n    \twhile i &lt; len(L) and j &lt; len(R):\r\n        if L&#x5B;i] &lt; R&#x5B;j]:\r\n            \tarr&#x5B;k] = L&#x5B;i]\r\n            \ti += 1\r\n        else:\r\n            \tarr&#x5B;k] = R&#x5B;j]\r\n            \tj += 1\r\n        k += 1\r\n\r\n    \twhile i &lt; len(L):\r\n        \tarr&#x5B;k] = L&#x5B;i]\r\n        \ti += 1\r\n        \tk += 1\r\n\r\n    \twhile j &lt; len(R):\r\n        \tarr&#x5B;k] = R&#x5B;j]\r\n        \tj += 1\r\n        \tk += 1\r\n\r\ndef PrintSortedList(arr):\r\n\tfor i in range(len(arr)):\r\n    \tprint(arr&#x5B;i], end=&quot; &quot;)\r\n\tprint()\r\n\r\narr = &#x5B;12, 11, 13, 5, 6, 7]\r\nprint(&quot;Given array is&quot;, end=&quot;\\n&quot;)\r\nPrintSortedList(arr)\r\nMergeSort(arr)\r\nprint(&quot;Sorted array is: &quot;, end=&quot;\\n&quot;)\r\nPrintSortedList(arr)\r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Time-Complexity-of-Merge-sort.png\"><img decoding=\"async\" class=\"alignnone wp-image-169396 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Time-Complexity-of-Merge-sort.png\" alt=\"Merge sort\" width=\"591\" height=\"242\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Time-Complexity-of-Merge-sort.png 591w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/Time-Complexity-of-Merge-sort-300x123.png 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/a><\/p>\n<p><strong>Time Complexity of Merge sort<\/strong><\/p>\n<ul>\n<li><strong>Worst Case: <\/strong>The worst time complexity for merge sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<li><strong>Average Case:<\/strong> The average time complexity for merge sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<li><strong>Best Case:<\/strong> The best time complexity for merge sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<\/ul>\n<p><strong>Advantages<\/strong><\/p>\n<ul>\n<li>The file size does not matter for this sorting technique.<\/li>\n<li>This technique is good for the data which are generally accessed in a sequence order. <span style=\"text-decoration: underline;\"><strong>For example,<\/strong><\/span> linked lists, tape drive, etc.<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>It requires more space when compared to other sorting techniques.<\/li>\n<li>It is comparatively less efficient than others.<\/li>\n<\/ul>\n<h3>Quick sort<\/h3>\n<p>Quick sort again uses the divide and conquer method to sort the elements of a List or an array. It targets the pivot elements and sorts the elements according to the selected pivot element.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>For example<\/strong><\/span><\/p>\n<ul>\n<li>We are provided with an array having the elements \u201c 1,8,3,9,4,5,7 \u201d.<\/li>\n<li>Let us assume \u201c 7 \u201d to be a pilot element.<\/li>\n<li>Now we will divide the array in such a manner that the left side contains the elements which are smaller than the pivot element \u201c 7 \u201d and the right side contains the elements greater than the pivot element \u201c 7 \u201d.<\/li>\n<li>We now have two arrays \u201c 1,3,4,5 \u201d and \u201c 8, 9 \u201d.<\/li>\n<li>Again, we have to divide both arrays just as the same as we did above. The only difference is that the pivot elements get changed.<\/li>\n<li>We need to divide the arrays till we get the single element in the array.<\/li>\n<li>At the end, collect all the pivot elements in a sequence from left to right and you will get the sorted array.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort.png\"><img decoding=\"async\" class=\"alignnone wp-image-169397 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort.png\" alt=\"quick_sort\" width=\"530\" height=\"381\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort.png 530w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort-300x216.png 300w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/a><\/p>\n<p><strong>Program for Quick sort<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\ndef Array_Partition( arr, lowest, highest ):\r\n\ti = ( lowest-1 )\r\n\tpivot_element = arr&#x5B; highest ]\r\n \r\n\tfor j in range( lowest, highest ):\r\n    \tif arr&#x5B; j ] &lt;= pivot_element:\r\n \r\n        \ti = i+1\r\n        \tarr&#x5B; i ], arr&#x5B; j ] = arr&#x5B; j ], arr&#x5B; i ]\r\n \r\n\tarr&#x5B; i+1 ], arr&#x5B; highest ] = arr&#x5B; highest ], arr&#x5B; i+1 ]\r\n\treturn ( i+1 )\r\n\r\ndef QuickSort( arr, lowest, highest ):\r\n\tif len( arr ) == 1:\r\n    \treturn arr\r\n\tif lowest &lt; highest:\r\n    \tpi = Array_Partition( arr, lowest, highest )\r\n \r\n    \tQuickSort( arr, lowest, pi-1 )\r\n    \tQuickSort( arr, pi+1, highest )\r\n \r\narr = &#x5B; 9, 6, 7, 8, 0, 4 ]\r\nn = len( arr )\r\nprint( &quot; Unsorted array: &quot;, arr )\r\nQuickSort( arr, 0, n-1 )\r\nprint( &quot; Sorted array using Quick Sort: &quot; )\r\nfor i in range( n ):\r\n\tprint( &quot; %d &quot; % arr&#x5B; i ] )\r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort_output.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169399\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort_output.png\" alt=\"quick_sort_output\" width=\"496\" height=\"289\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort_output.png 496w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/quick_sort_output-300x175.png 300w\" sizes=\"(max-width: 496px) 100vw, 496px\" \/><\/a><\/p>\n<p><strong>Time Complexity of Quick sort<\/strong><\/p>\n<ul>\n<li><strong>Worst Case: <\/strong>The worst time complexity for Quick sort is O(<em>n<\/em><sup>2<\/sup>).<\/li>\n<li><strong>Average Case:<\/strong> The average time complexity for Quick sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<li><strong>Best Case:<\/strong> The best time complexity for Quick sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<\/ul>\n<p><strong>Advantages<\/strong><\/p>\n<ul>\n<li>It is known as the best sorting algorithm in Python.<\/li>\n<li>It is useful while handling large amount of data.<\/li>\n<li>It does not require additional space.<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>Its worst-case complexity is similar to the complexities of bubble sort and insertion sort.<\/li>\n<li>This sorting method is not useful when we already have the sorted list.<\/li>\n<\/ul>\n<h3>Heap sort<\/h3>\n<p>Heap sort is the advanced version of Binary search tree. In heap sort, the greatest element of an array is placed on the root of the tree always and then, compared with the root with the leaf nodes.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>For example:<\/strong><\/span><\/p>\n<ul>\n<li>We are provided with an array having the elements \u201c 40, 100, 30, 50, 10 \u201d.<\/li>\n<li>In <strong>\u201c step 1 \u201d<\/strong> we made a tree according to the presence of the elements in the array.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_1.png\"><img decoding=\"async\" class=\"alignnone wp-image-169403 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_1.png\" alt=\"heap_sort \" width=\"499\" height=\"343\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_1.png 499w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_1-300x206.png 300w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/a><\/p>\n<ul>\n<li>In \u201c<strong> step 2 \u201d<\/strong> we are making a maximum heap i.e. to arrange the elements in the descending order. The greatest element will reside at the top (root) and the smallest element resides at the bottom (leaf nodes). The given array becomes \u201c 100, 50, 30, 40, 10 \u201d.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/maximum-heap.png\"><img decoding=\"async\" class=\"alignnone wp-image-169404 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/maximum-heap.png\" alt=\"maximum heap - Step 2\" width=\"502\" height=\"354\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/maximum-heap.png 502w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/maximum-heap-300x212.png 300w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<ul>\n<li>In <strong>\u201c step 3 \u201d<\/strong>, we are making the minimum heap so that we can find the minimum elements of an array. By doing this, we get the maximum and the minimum elements.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_4.png\"><img decoding=\"async\" class=\"alignnone wp-image-169405 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_4.png\" alt=\"heap_sort - Step 3\" width=\"500\" height=\"344\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_4.png 500w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/heap_sort_4-300x206.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<ul>\n<li>In <strong>\u201c step 4 \u201d<\/strong> by performing the same steps we get the sorted array.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/last-node.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-169408\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/last-node.png\" alt=\"last node\" width=\"498\" height=\"238\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/last-node.png 498w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/last-node-300x143.png 300w\" sizes=\"(max-width: 498px) 100vw, 498px\" \/><\/a><\/p>\n<p><strong>Program for Heap sort<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">```\r\ndef HeapSortify( arr, n, i ):\r\n\tlarger_element = i\r\n\tleft = 2 * i + 1\r\n\tright = 2 * i + 2\r\n\r\n\tif left &lt; n and arr&#x5B; larger_element ] &lt; arr&#x5B; left ]:\r\n    \tlarger_element = left\r\n\tif right &lt; n and arr&#x5B; larger_element ] &lt; arr&#x5B; right ]:\r\n    \tlarger_element = right\r\n\tif larger_element != i:\r\n    \tarr&#x5B; i ], arr&#x5B; larger_element ] = arr&#x5B; larger_element ], arr&#x5B; i ]\r\n    \tHeapSortify( arr, n, larger_element )\r\n\r\ndef HeapSort( arr ):\r\n\tn = len( arr )\r\n\r\n\tfor i in range( n\/\/2 - 1, -1, -1 ):\r\n    \tHeapSortify( arr, n, i )\r\n\r\n\tfor i in range( n-1, 0, -1 ):\r\n    \tarr&#x5B; i ], arr&#x5B; 0 ] = arr&#x5B; 0 ], arr&#x5B; i ]\r\n    \tHeapSortify( arr, i, 0 )\r\n \r\narr = &#x5B; 11, 10, 12, 4, 5, 6 ]\r\nprint( &quot; The unsorted array is: &quot;, arr )\r\nHeapSort( arr )\r\nn = len( arr )\r\nprint( &quot; The sorted array sorted by the Heap Sort: &quot; )\r\nfor i in range( n ):\r\n\tprint( arr&#x5B; i ] )\r\n\r\n```\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-169409 size-full\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array-1.png\" alt=\"heap sort array\" width=\"552\" height=\"240\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array-1.png 552w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2021\/04\/array-1-300x130.png 300w\" sizes=\"(max-width: 552px) 100vw, 552px\" \/><\/a><\/p>\n<p><strong>Time Complexity of Heap sort<\/strong><\/p>\n<ul>\n<li><strong>Worst Case: <\/strong>The worst time complexity for Heap sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<li><strong>Average Case:<\/strong> The average time complexity for Heap sort is O(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<li><strong>Best Case:<\/strong> The best time complexity for Heap sort isO(<em>n<\/em> log(<em>n<\/em>)).<\/li>\n<\/ul>\n<p><strong>Advantages<\/strong><\/p>\n<ul>\n<li>It is mostly used because of its productivity.<\/li>\n<li>It can be implemented as an in-place algorithm.<\/li>\n<li>It does not require large storage.<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>Needs space for sorting the elements.<\/li>\n<li>It makes the tree for sorting the elements.<\/li>\n<\/ul>\n<h3>Comparison Between the Sorting Techniques<\/h3>\n\n<div id=\"tablepress-2399-scroll-wrapper\" class=\"tablepress-scroll-wrapper\">\n<table id=\"tablepress-2399\" class=\"tablepress tablepress-id-2399 tablepress-responsive\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">Sorting Method<\/th><th class=\"column-2\">Best case time complexity<\/th><th class=\"column-3\">Average case time complexity<\/th><th class=\"column-4\">Worst case time complexity<\/th><th class=\"column-5\">Space complexity<\/th><th class=\"column-6\">Stability<\/th><th class=\"column-7\">In - place<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\"><strong>Bubble sort<\/strong><\/td><td class=\"column-2\">O(n)<\/td><td class=\"column-3\">O(n2)<\/td><td class=\"column-4\">O(n2)<\/td><td class=\"column-5\">O(1)<\/td><td class=\"column-6\">Yes<\/td><td class=\"column-7\">Yes<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\"><strong>Insertion sort<\/strong><\/td><td class=\"column-2\">O(n)<\/td><td class=\"column-3\">O(n2)<\/td><td class=\"column-4\">O(n2)<\/td><td class=\"column-5\">O(1)<\/td><td class=\"column-6\">Yes<\/td><td class=\"column-7\">Yes<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\"><strong>Quick sort<\/strong><\/td><td class=\"column-2\">O(n log(n))<\/td><td class=\"column-3\">O(n log(n))<\/td><td class=\"column-4\">O(n2)<\/td><td class=\"column-5\">O(N)<\/td><td class=\"column-6\">No<\/td><td class=\"column-7\">Yes<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\"><strong>Merge sort<\/strong><\/td><td class=\"column-2\">O(n log(n))<\/td><td class=\"column-3\">O(n log(n))<\/td><td class=\"column-4\">O(n log(n))<\/td><td class=\"column-5\">O(N)<\/td><td class=\"column-6\">Yes<\/td><td class=\"column-7\">No<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\"><strong>Heap sort<\/strong><\/td><td class=\"column-2\">O(n log(n))<\/td><td class=\"column-3\">O(n log(n))<\/td><td class=\"column-4\">O(n log(n))<\/td><td class=\"column-5\">O(1)<\/td><td class=\"column-6\">No<\/td><td class=\"column-7\">Yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<!-- #tablepress-2399 from cache -->\n<p>In the above comparison table \u201c O \u201c is the Big Oh notation explained above whereas \u201c n \u201d and \u201c N \u201d means the size of the input.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<p><span style=\"color: #ff6600;\"><strong>Q #1) What is sort () in Python?<\/strong><\/span><\/p>\n<p><strong>Answer:<\/strong> In Python sort() is a function that is used to sort the lists or arrays in a specific order. This function eases the process of sorting while working on the large projects. It is very helpful for the developers.<\/p>\n<p><strong><span style=\"color: #ff6600;\">Q #2) How do you sort in Python?<\/span><\/strong><\/p>\n<p><strong>Answer:<\/strong> Python provides various sorting techniques that are used to sort the element. <span style=\"text-decoration: underline;\"><strong>For example,<\/strong><\/span> Quick sort, Merge sort, Bubble sort, Insertion sort, etc. All the sorting techniques are efficient and easy to understand.<\/p>\n<p><strong><span style=\"color: #ff6600;\">Q #3) How does Python sort () work?<\/span><\/strong><\/p>\n<p><strong>Answer:<\/strong> The sort() function takes the given array as an input from the user and sorts it in a specific order using the sorting algorithm. The selection of the algorithm depends upon the user choice. Users can use Quick sort, Merge sort, Bubble sort, Insertion sort, etc depending upon the user&#8217;s needs.<\/p>\n<h2>Conclusion<\/h2>\n<p>In the above tutorial, we discussed the sort technique in Python along with the general sorting techniques.<\/p>\n<ul>\n<li>Bubble Sort<\/li>\n<li>Insertion Sort<\/li>\n<li>Quick Sort<\/li>\n<\/ul>\n<p>We learned about their time complexities and advantages &amp; disadvantages. We also compared all the above techniques.<\/p>\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/python\/\">Visit Here To Learn Python From Scratch<\/a><\/strong><\/p>\n\r\n\t\t\t<div id=\"daexthefup-container\"\r\n\t\t\t\tclass=\"daexthefup-container daexthefup-layout-stacked daexthefup-alignment-center\"\r\n\t\t\t\tdata-post-id=\"169381\">\r\n\r\n\t\t\t\t<div class=\"daexthefup-feedback\">\r\n\t\t\t\t\t<div class=\"daexthefup-text\">\r\n\t\t\t\t\t\t<h3 class=\"daexthefup-title\">Was this helpful?<\/h3>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"daexthefup-buttons-container\">\r\n\t\t\t\t\t\t<div class=\"daexthefup-buttons\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-yes daexthefup-button daexthefup-button-type-icon\" data-value=\"1\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-up-cls-1{fill:#c9c9c9;}.thumb-up-cls-2{fill:#e1e1e1;}.thumb-up-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_up\">\r\n                        <path class=\"thumb-up-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-up-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"20\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,9.06l-.49-.1c-.81-.17-1.61.35-1.78,1.16l-5.3,11.74c-.17.81,3.16,1.61,3.97,1.78l1.96.41c.81.17,1.61-.35,1.78-1.16l2.18-10.27c.34-1.61-.7-3.21-2.31-3.56Z\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,20h-18.67c-.83,0-1.5.67-1.5,1.5v12c0,.83.67,1.5,1.5,1.5h16.27c.71,0,1.33-.5,1.47-1.21l2.4-12c.19-.93-.53-1.8-1.47-1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-no daexthefup-button daexthefup-button-type-icon\" data-value=\"0\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-down-cls-1{fill:#c9c9c9;}.thumb-down-cls-2{fill:#e1e1e1;}.thumb-down-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_down\">\r\n                        <path class=\"thumb-down-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-down-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"13\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,38.94l-.49.1c-.81.17-1.61-.35-1.78-1.16l-5.3-11.74c-.17-.81,3.16-1.61,3.97-1.78l1.96-.41c.81-.17,1.61.35,1.78,1.16l2.18,10.27c.34,1.61-.7,3.21-2.31,3.56Z\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,28h-18.67c-.83,0-1.5-.67-1.5-1.5v-12c0-.83.67-1.5,1.5-1.5h16.27c.71,0,1.33.5,1.47,1.21l2.4,12c.19.93-.53,1.8-1.47,1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-comment\">\r\n\t\t\t\t\t<div class=\"daexthefup-comment-top-container\">\r\n\t\t\t\t\t\t<label id=\"daexthefup-comment-label\" class=\"daexthefup-comment-label\"><\/label>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-container\">\r\n\t\t\t\t\t\t\t\t<div id=\"daexthefup-comment-character-counter-number\"\r\n\t\t\t\t\t\t\t\t\tclass=\"daexthefup-comment-character-counter-number\"><\/div>\r\n\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-text\"><\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<textarea id=\"daexthefup-comment-textarea\" class=\"daexthefup-comment-textarea\"\r\n\t\t\t\t\t\t\t\tplaceholder=\"Type your message\"\r\n\t\t\t\t\t\t\t\tmaxlength=\"\r\n\t\t\t\t\t\t\t\t400\t\t\t\t\t\t\t\t\t\"><\/textarea>\r\n\t\t\t\t\t<div class=\"daexthefup-comment-buttons-container\">\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-submit daexthefup-button\">Submit<\/button>\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-cancel daexthefup-button\">Cancel<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-successful-submission-text\">Thanks for your feedback!<\/div>\r\n\r\n\t\t\t<\/div>\r\n\r\n\t\t\t","protected":false},"excerpt":{"rendered":"<p>Learn how to use the Python Sort function for sorting lists, arrays, dictionaries, etc using various sorting methods and algorithms in Python: Sorting is a technique that is used for sorting the data in a sequence order either in ascending or descending order. Most of the time the data of &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Sort: Sorting Methods And Algorithms In Python\" class=\"read-more button\" href=\"https:\/\/www.softwaretestinghelp.com\/python-sorting-methods\/#more-169381\" aria-label=\"Read more about Python Sort: Sorting Methods And Algorithms In Python\">Read more<\/a><\/p>\n","protected":false},"author":9,"featured_media":169520,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_helpful_pro_status":1,"footnotes":""},"categories":[407],"tags":[],"class_list":{"0":"post-169381","1":"page","2":"type-page","3":"status-publish","4":"has-post-thumbnail","6":"category-python"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/169381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/comments?post=169381"}],"version-history":[{"count":0,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/169381\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media\/169520"}],"wp:attachment":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media?parent=169381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/categories?post=169381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/tags?post=169381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}