Skip to content

Instantly share code, notes, and snippets.

@abdulateef
Last active December 9, 2018 11:26
Show Gist options
  • Save abdulateef/058aa4a974334f7a7196ad50ff5c4433 to your computer and use it in GitHub Desktop.
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.
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