dear I have this list @@spelers = Speler.new(''Jan Janssens'', ''M'', 5, ''SR''),Speler.new(''Leen Leniksen'', ''V'', 7), Speler.new(''Piet Pieters'', ''M'', 3), Speler.new(''Els Elsenbocht'', ''V'', 1, ''J''), Speler.new(''Karel Carlsen'', ''M'', 8), Speler.new(''Mieke Mieters'', ''V'', 9, ''P''), Speler.new(''John Johanses'', ''M'', 5, ''J''), Speler.new(''Veerle Veldsen'', ''V'', 3) and I need to sort them into a top three for every mail and female in this list the M is for mail the V for female. I have a def gender? geslacht @geslacht = geslacht end I know you could solve it like the example below however I would like to do it with an IF structure or with a bubble sort but not able to figure this out could someone help me out here and give me an example on how to solve this def self.top3 geslacht per_geslacht(geslacht).sort_by { |x| x.score }.to_a.slice(-3,3).reverse end when it''s an if structure I should start somehow with if speler.score1 > speler.score2 print speler.score1 else print speler.score2 but after this I,m lost since I don''t know how to difference the first person from the second thanks for your help and feedback Paul -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Paul Private wrote:> I know you could solve it like the example below however I would like to > do it with an IF structure or with a bubble sort but not able to figure > this outWhy? Is it slow? Does it not do exactly what you want? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
not that it''s slow but I would like to achieve the same with the if structure and was wondering how this can be done if someone could help me with an example it would be much appreciated Daniel Waite wrote:> Paul Private wrote: >> I know you could solve it like the example below however I would like to >> do it with an IF structure or with a bubble sort but not able to figure >> this out > > Why? Is it slow? Does it not do exactly what you want?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
since I''m new to Ruby I try to explore my horizons and would like to know how it''s done with an if structure or with bubble sort thanks again for providing an example Paul Paul Private wrote:> not that it''s slow but I would like to achieve the same with the if > structure and was wondering how this can be done if someone could help > me with an example it would be much appreciated > > Daniel Waite wrote: >> Paul Private wrote: >>> I know you could solve it like the example below however I would like to >>> do it with an IF structure or with a bubble sort but not able to figure >>> this out >> >> Why? Is it slow? Does it not do exactly what you want?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Isn''t there anybody who would like to help me out here with an example? Paul Private wrote:> since I''m new to Ruby > I try to explore my horizons and would like to know how it''s done with > an if structure or with bubble sort > thanks again for providing an example > Paul > > > Paul Private wrote: >> not that it''s slow but I would like to achieve the same with the if >> structure and was wondering how this can be done if someone could help >> me with an example it would be much appreciated >> >> Daniel Waite wrote: >>> Paul Private wrote: >>>> I know you could solve it like the example below however I would like to >>>> do it with an IF structure or with a bubble sort but not able to figure >>>> this out >>> >>> Why? Is it slow? Does it not do exactly what you want?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---