Skip to content

eseite47/First-Sorting-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

First-Sorting-Algorithm

My first sorting algorithm

Challenge found on cadewars.com: Given an array of numbers, sort them in such a manner that all the odd numbers in the array are sorted in ascending order and the even numbers are sorted in descending order after the last odd number. For example [1,2,3,4,5,6,7,8,9] produces the output [1,3,5,7,9,8,6,4,2]. If the array contains decimals, round them down while checking for odd/even. The output must have the original numbers!

Swap and SwapTest These program reflect my first approach, which was to use a sorting method inspired by the bubble sort. I have not been able to get the swap to work properly yet.

SwapTwo and SwapTestTwo In a different approach, I separated odd and even numbers into two separate arrays, and the sorted each array. This worked!

About

Odd/Even Sorting algorithm

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages