-
-
Save dogac00/7391be34fd85ed55cf008555336cd5f1 to your computer and use it in GitHub Desktop.
List the Odds (List Just the Odds in an Array)
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 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