From: 7stud -- Date: 2008-01-23T16:30:12+09:00 Subject: Re: Alphabetizing Zenki Nine wrote: > Hi, > > I'm trying to write a code where I can alphabetize the players last_name > with its batting average > > players_avg= << PLAYERS > Barry Bonds, .293 > Mike Gallego, .263 > Ichiro Suzuki, .396 > Tony Gwynn, .403 > Alex Rodriguez, .310 > PLAYERS > > players = presidents_avg.strip.collect { |players| players.strip > }.compact > > #initialiating players_by_last_name with an empty array > players_by_last_name = [] Try this: players_avg = <arr2[1] end #output data: results.each() do |arr| puts "%s, %s %s" % [arr[1], arr[0], arr[2]] end --output:-- Bonds, Barry .293 Gallego, Mike .263 Gwynn, Tony .403 Rodriguez, Alex .310 Suzuki, Ichiro .396 -- Posted via http://www.ruby-forum.com/.