a sort question

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

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?

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:

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:

Isn't there anybody who would like to help me out here with an example?

Paul Private wrote: