when I do a sort like this it's working correctly
class Test
cursussen = ["ruby","php","c","cobalt","java"]
z=cursussen.sort { |a, b| a <=> b }
puts z

end

I don't understand why I can't get it to work when I use this
require "oefeningen/_cursus"
class Cursus_applic
  cursussen = [Cursus.new("Ruby - 1","Jan", 18.15, 10),
  Cursus.new("Ruby - 2","Piet", 18.15, 8),
  Cursus.new("Java - 1","Els", 14, 15),
  Cursus.new("Java - 2","Jan", 14, 10),
  Cursus.new("Java - 3","Piet", 18.15, 8)
  ]




  puts '5. Alle Java-cursussen, daarna alle andere cursussen: '

  Java, other = cursussen.partition {|cursus| cursus.naam?("Java") }
  puts Java, other

  puts '6. Alle cursussen gesorteerd op cursus naam: '
 z=cursussen.sort { |a, b| a <=> b }
 puts z
end
can you or someone help me out
thanks for your help

Paul
John Joyce wrote:
> On Dec 1, 2007, at 11:58 AM, Todd Benson wrote:
> 
>>> code mentioned earlier I get a error message like this
>>
>> names = %w| tiger bear monkey zebra giraffe |
>> zoo = []
>> names.each { |n| zoo << Animal.new(n) }
>>
>> zoo.each { |a| puts a.name }
>> puts "\n------------\n"
>> zoo_in_order = zoo.sort_by{ |a| a.name }
>> zoo.each { |a| puts a.name }
>>
>> Todd
>>
> Even consider this, simply have class Cursus inherit from another
> class that already implements methods you need such as .sort
> Enumerable or Array might be convenient, but I didn't read all of
> your class Cursus closely...
> In defining your class it is easy to override any inherited method,
> and generally a lot less work to inherit than to create everything
> from nothing.
> 
> Is het voor en hogeschool in het Nederlands? Polytechnische school?

-- 
Posted via http://www.ruby-forum.com/.