GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Reverse Sort a String - Python - GeeksforGeeks Reverse Sort a String - PythonLast Updated : 12 Jul, 2025 The goal is to take a given string and arrange its characters in descending order based on their Unicode values. For example, in the string "geeksforgeeks", the characters will be sorted from highest to lowest, resulting in a new string like "ssrokkggfeeeee". Let's understand different methods to perform this operation efficiently. Using sorted() with reverse=TrueThis is the most straightforward way to reverse sort a string. sorted() function lets us easily sort elements and the reverse=True parameter ensures the order is descending.
Output ssrokkggfeeee Explanation:
Using list.sort()If we are working with a string that has been converted into a list, we can use sort() method to reverse sort it in place. This method is slightly faster for large strings as it avoids creating a new list.
Output ssrokkggfeeee Explanation:
Using recursionRecursion provides an unconventional approach to reverse sorting a string. It identifies the maximum character in the string repeatedly and appends it to the result.
Output ssrokkggfeeee Explanation:
Using for loopIf we want more control and prefer to manually handle the process, we can use a for loop to reverse sort a string.
Output ssrokkggfeeee Explanation:
Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |