{"id":8418,"date":"2020-05-18T22:44:45","date_gmt":"2020-05-18T17:14:45","guid":{"rendered":"https:\/\/tutorials.eyehunts.com\/?p=8418"},"modified":"2021-08-13T18:52:16","modified_gmt":"2021-08-13T13:22:16","slug":"difference-between-sort-vs-sorted-python-function","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/","title":{"rendered":"Difference between sort vs sorted Python Function"},"content":{"rendered":"\n<p>You can sort the list using the sort() or sorted() Python function.  You must be thinking about then what is the difference between sort() and sorted() function.<\/p>\n\n\n\n<p>The main difference between the list&nbsp;<code>sort()<\/code> and&nbsp;<code>sorted()<\/code>&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-functions-basics-tutorial-example\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python function<\/a> is that the&nbsp;<code>sort()<\/code>&nbsp;the function will modify the list it is called on. The&nbsp;sorted()&nbsp;function will create a new list containing a sorted version of the list it is given.&nbsp;<\/p>\n\n\n\n<p>Let&#8217;s see How both used and their syntax:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> sorted(list)<\/code><\/pre>\n\n\n\n<p>vs <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list.sort()<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><code>list.sort<\/code>&nbsp;mutates the list in place &amp; returns&nbsp;<code>None<\/code><\/li><li><code>sorted<\/code>&nbsp;takes any iterable &amp; returns a new list, sorted.<\/li><\/ul>\n\n\n\n<p>So you can understand is that the\u00a0<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-sorted-function-sort-string-list-tuple-dictionary\/\"><code>sorted()<\/code>\u00a0function<\/a> will return a list so you must assign the returned data to a new variable. The\u00a0<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-list-array-methods-remove-insert-pop-reverse-count-sort-append-copy\/\"><code>sort()<\/code>\u00a0function<\/a> modifies the list in place and has no return value.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example between sort vs sorted Python Function<\/strong><\/h2>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Sorted() Function <\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sorted(iterable, key=key, reverse=reverse)<\/code><\/pre>\n\n\n\n<p><strong>Code<\/strong><\/p>\n\n\n\n<pre>number_list = [1, 3, 2, 4]\n \nprint(sorted(number_list))\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong> [1, 2, 3, 4]<\/p>\n\n\n\n<p><strong>Read more:<\/strong> <a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-sorted-function-sort-string-list-tuple-dictionary\/\">Python sorted function | Sort string, list, tuple, dictionary<\/a><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>sort() Function<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.sort(reverse=True|False, key=myFunc)<\/code><\/pre>\n\n\n\n<p><strong>code<\/strong><\/p>\n\n\n\n<pre>\nnumbers = [5, 3, 4, 2, 1]\n \n# Sorting list of Integers in ascending \nnumbers.sort()\n \nprint(numbers)\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong>&nbsp;[1, 2, 3, 4, 5]<\/p>\n\n\n\n<p><strong>Read more:<\/strong> <a href=\"https:\/\/tutorial.eyehunts.com\/\/java\/python-sort-list-array-function-strings-number-list\/\">Python sort list (Array) | sorted function \u2013 Strings (alphabetically), Number, list<\/a><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>All common sort vs sorted python Questions<\/strong><\/h3>\n\n\n\n<p>Here are some common doubt between <strong>sort() vs sorted()<\/strong> function in python:-<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">1. When is one preferred over the other?<\/h3>\n\n\n\n<p><strong>Answer:<\/strong> Use&nbsp;<code>list.sort()<\/code>&nbsp;when you want to mutate the list&nbsp;<code>sorted()<\/code>&nbsp;when you want a new sorted object back. Use&nbsp;<code>sorted()<\/code>&nbsp;when you want to sort something that is an <a rel=\"noreferrer noopener\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-iterable-object-lists-tuples-dictionaries-and-sets\/\" target=\"_blank\">iterable object<\/a>, not a list&nbsp;<em>yet<\/em>.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">2. Which is more efficient? By how much?<\/h4>\n\n\n\n<p><strong>Answer:<\/strong> For lists,&nbsp;<code>list.sort()<\/code>&nbsp;is faster than&nbsp;<code>sorted()<\/code>&nbsp;because it doesn&#8217;t have to create a copy. For any other <a rel=\"noreferrer noopener\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-iterable-object-lists-tuples-dictionaries-and-sets\/\" target=\"_blank\">iterable object<\/a>, you have no choice.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">3. Can a list be reverted to the unsorted state after&nbsp;<code>list.sort()<\/code>&nbsp;has been performed?<\/h4>\n\n\n\n<p><strong>Answer:<\/strong> No, you cannot retrieve the original positions. Once you called&nbsp;<code>list.sort()<\/code>&nbsp;the original order is gone.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you know any other differences and doubts about this tutorial.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong><br>IDE:\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>\u00a02020.1.1 (Community Edition)<br>macOS 10.15.4<br><strong>Python 3.7<\/strong><br>All<strong>\u00a0Python Examples\u00a0are in\u00a0Python\u00a03<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You can sort the list using the sort() or sorted() Python function. You must be thinking about then what is the difference between sort() and sorted() function. The main difference between the list&nbsp;sort() and&nbsp;sorted()&nbsp;Python function is that the&nbsp;sort()&nbsp;the function will modify the list it is called on. The&nbsp;sorted()&nbsp;function will create a new list containing a&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Difference between sort vs sorted Python Function<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[38,83],"post_series":[],"class_list":["post-8418","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-function","tag-python-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Difference between sort vs sorted Python Function - EyeHunts<\/title>\n<meta name=\"description\" content=\"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Difference between sort vs sorted Python Function - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-18T17:14:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-13T13:22:16+00:00\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\",\"name\":\"Difference between sort vs sorted Python Function - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"datePublished\":\"2020-05-18T17:14:45+00:00\",\"dateModified\":\"2021-08-13T13:22:16+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Difference between sort vs sorted Python Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Difference between sort vs sorted Python Function - EyeHunts","description":"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()","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:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/","og_locale":"en_US","og_type":"article","og_title":"Difference between sort vs sorted Python Function - EyeHunts","og_description":"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()","og_url":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/","og_site_name":"Tutorial","article_published_time":"2020-05-18T17:14:45+00:00","article_modified_time":"2021-08-13T13:22:16+00:00","author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/","url":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/","name":"Difference between sort vs sorted Python Function - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"datePublished":"2020-05-18T17:14:45+00:00","dateModified":"2021-08-13T13:22:16+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"The main difference between the list sort() and sorted() Python function is that the sort() function will modify the list it is called on. The sorted()","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-sort-vs-sorted-python-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Difference between sort vs sorted Python Function"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":8435,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sorted-function-sort-string-list-tuple-dictionary\/","url_meta":{"origin":8418,"position":0},"title":"Python sorted function | Sort string, list, tuple, dictionary","author":"Rohit","date":"May 11, 2020","format":false,"excerpt":"Python sorted() function is used to sort string, list, tuple, dictionary, etc and it returns a list with the elements in a sorted manner, without modifying the original sequence. Syntax sorted(iterable, key=key, reverse=reverse) Parameter Values The sorted() method takes an of three parameters: iterable\u00a0- A sequence or collection or any\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python sorted function Sort the list of Number String","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-sorted-function-Sort-the-list-of-Number-String-.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8410,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-list-array-alphabetically-example-data-structure\/","url_meta":{"origin":8418,"position":1},"title":"Python sort list (Array) Alphabetically Example | data structure","author":"Rohit","date":"May 8, 2020","format":false,"excerpt":"How to sort the words alphabetically in List? Given List:- ['Zuba', 'Alpha', 'Beta', 'Thor', 'Gama', 'Tony'] Answer: You can use the sort() or sorted() python function for sort lists\u00a0alphabetically in python. sort() function - will modify the list it is called on.sorted() function- will create a new list containing a\u00a0sorted\u00a0version\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python sort list (Array) Alphabetically","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-sort-list-Array-Alphabetically.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-sort-list-Array-Alphabetically.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-sort-list-Array-Alphabetically.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":19776,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-list-of-dictionaries-example-code\/","url_meta":{"origin":8418,"position":2},"title":"Python sort list of dictionaries | Example code","author":"Rohit","date":"September 15, 2021","format":false,"excerpt":"Use lambda function with sorted() inbuilt function to sort the list of dictionaries in Python. Pass the list containing dictionaries and keys to the sorted method. Example sort list of dictionaries in Python A simple example code demonstrates the working of sorted() with lambda. We sort the list of dict\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-sort-list-of-dictionaries.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-sort-list-of-dictionaries.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-sort-list-of-dictionaries.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-sort-list-of-dictionaries.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-sort-list-of-dictionaries.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":16199,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-list-of-strings-with-numbers-example-code\/","url_meta":{"origin":8418,"position":3},"title":"Python sort list of strings with numbers | Example code","author":"Rohit","date":"July 7, 2021","format":false,"excerpt":"If you have a list of strings but contain the number and want to sort it then use the sort method with key=float to sort the list. Sort list of strings with numbers list.sort(key=int) or with float sort(key=float) Example Sort numeric strings in a list in Python Simple python example\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/07\/Python-sort-list-of-strings-with-numbers.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8392,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-string-alphabetically-letters-ascending-descending-order\/","url_meta":{"origin":8418,"position":4},"title":"Python sort string | alphabetically letters ascending\/descending order","author":"Rohit","date":"May 20, 2020","format":false,"excerpt":"You can sort string in python using \"join() + sorted()\" and \"sorted() + reduce() + lambda\" method combinations. String can sort the letter\/characters in ascending or descending alphabetically order. Example of Python sort string Let' see the example program in both ways. 1. Using join() + sorted() First sorted list\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python sort string alphabetically letters ascending descending order","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-sort-string-alphabetically-letters-ascending-descending-order.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8386,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-list-array-function-strings-number-list\/","url_meta":{"origin":8418,"position":5},"title":"Python sort list (Array) | sorted function &#8211; Strings (alphabetically), Number, list","author":"Rohit","date":"May 7, 2020","format":false,"excerpt":"The python sort() function is used to sorts the elements of a given list. It sorts the list ascending, descending, or user-defined order where ascending order is by default. Note: Ascending order is by default in sort() method.It changes the original list and doesn't return any value. Syntax list.sort(reverse=True|False, key=myFunc)\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python sort list Array","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/07\/Python-sort-list-Array.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/8418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=8418"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/8418\/revisions"}],"predecessor-version":[{"id":17949,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/8418\/revisions\/17949"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=8418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=8418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=8418"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=8418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}