The basic idea behind this is to have 3 arrays.

the first one is the original unsorted array.

the second one will be the final sorted array

and the third one will be kind of a compliment.

a comparison of the first object (in this case words/letters) will be

done with

all of the other objects and if it is the “smallest” object, it will be

pushed into the sorted array. if it is compared with an object and it is

“bigger” than that object, it is pushed into the compliment array. when

an object is pushed into the sorted array, the original unsorted array

will become empty and the compliment array will be equated to the

unsorted array and this repeats itself until all the objects have been

dealt with. I’ll paste the code but I’m having issues because I get a

bizarre sorted array. Please tell me what’s wrong or what I can do to

fix it. I do not want to use the bubble sort though.

#original unsorted array

array = [‘a’,‘b’,‘c’,‘d’]

#final sorted array

sortedarray = []

#compliment array

unsortedarray = []

#placeholder for length comparison

placeholder = array

x=0

y=1

#this while block makes sure that the length of the sorted

#array is equal to the length of the original array

while sortedarray.length != placeholder.length

#this while block makes sure that every element is

#compared, and no object is the ‘smallest’ twice.

```
while y != array.length
if array[x] < array[y]
unsortedarray.push array[y]
y=y+1
else
unsortedarray.push array[x]
x=y
y=y+1
end
end
```

#erase the original array and replace it with the new unsorted array

sortedarray.push array[x]

array = []

array.push unsortedarray[0…unsortedarray.length]

y=1

x=0

end

## puts sortedarray

when this program runs, I expected the same original array to be

printed, then I’ll go ahead to test it with mixed arrangements… but it

didn’t turn out well… what did I do wrong or what should I try?