------ art_129943_19337566.1152464313373
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
I'm back already :). Basically I'm trying to take James original recursion
version and do it with recursion. Anyway, my questions are below in the
<---------------- lines.
TIA
Stuart
def sort(list)
sorted ]
unsorted ]
puts 'here is list: '
puts list <------ Here i'm outputing the list I put in to the method -
prints out the entire list
puts
lowest il
list.each do |item|
if lowest nil || item < lowest
lowest tem
end
end
sorted.push(lowest)
# make a new unsorted list, minus the low guy
unsorted ]
added alse
list.each do |item|
if added false and item lowest
added rue
else
unsorted.push(item)
end
end
puts 'Here is the unsorted list'
puts unsorted
puts
puts 'Here is the sorted list'
puts sorted
puts
puts 'Here is list' <----------------------- Here though, the list is
empty (at least of values). Something I don't get, since I didn't see any
.delete
puts
puts 'list size is: '<---------------------------yet here the size
returned is 5 the number of original elements.
puts list.size
# third step (from James' is where he returns control to method (or back
to recursion)
#if list.size 0
# sorted
#else
# recursive_sort(unsorted, sorted)
#end
end #end of method
mylist 'ten', 'eight', 'one', 'six', 'five']
sort mylist
------ art_129943_19337566.1152464313373--