Exercise 1: Sorting a List of Strings
Implement a Python script that sorts a list of strings in lexicographical order using any sorting algorithm. You can also explore sorting strings based on custom criteria, such as length or alphabetical order.
Exercise 2: Sorting a List of Custom Objects
Define a Python class representing custom objects and implement sorting functionality for lists of these objects. Use either the built-in sorting functions or implement sorting algorithms tailored to the specific properties of the custom objects.
Exercise 3: Top-K Elements
Write a Python function that takes a list of numbers and an integer k as input and returns the top-k elements from the list, sorted in descending order. You can use sorting algorithms like quick select to efficiently find the top-k elements.
Exercise 4: Sorting Dictionary by Values
Define a Python dictionary and write a function that sorts it based on the values in ascending or descending order. You can use any sorting algorithm or the built-in sorted() function with custom comparison functions.
Exercise 5: Sorting a List of Tuples
Implement a Python program that sorts a list of tuples based on specific elements within the tuples. You can customize the sorting criteria by providing key functions to the sorting algorithms.