Last active
December 9, 2018 11:26
-
-
Save abdulateef/058aa4a974334f7a7196ad50ff5c4433 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 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([90, 45, 66])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment