Created
January 19, 2019 08:55
-
-
Save antonnifo/a8a75298b27341ade9c8e87d5fafcd07 to your computer and use it in GitHub Desktop.
Write a function my_sort which takes in a list of numbers (integers). The function should return a list of sorted numbers such that odd numbers come first and even numbers come last.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def my_sort(numbers): | |
| odd = [n for n in numbers if n % 2 != 0] | |
| even = [n for n in numbers if n % 2 == 0] | |
| return sorted(odd) + sorted(even) | |
| print( my_sort([60, 25, 88])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment