Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dogac00
Created March 23, 2018 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogac00/7391be34fd85ed55cf008555336cd5f1 to your computer and use it in GitHub Desktop.
Save dogac00/7391be34fd85ed55cf008555336cd5f1 to your computer and use it in GitHub Desktop.
List the Odds (List Just the Odds in an Array)
def sort_array(arr):
oddarr=[]
for i in arr:
if(i%2!=0):
oddarr.append(i)
oddarr=sorted(oddarr)
j=0
for i, item in enumerate(arr):
if(arr[i]%2!=0):
arr[i]=oddarr[j]
j+=1
return arr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment