[Solved] Sort a list of integers basis the remainder they leave when divided by 5 in an ascending order? [closed]
Python’s sort() has the optional argument key. You can use a lambda function as the key like so: numbers = [1, 9, 35, 12, 13, 21, 10] numbers.sort(key=lambda i: i % 5) print(numbers) A quick explanation of what’s going on here: A lambda function is a function that is defined in-line and isn’t named. lambda … Read more