From: William James Date: 2005-10-11T18:41:52+09:00 Subject: Re: Sort pseudo-lists pete boardman wrote: > Is it easy to > sort the array of arrays by their second, third, and fourth entries > as well: > > ie such that > > [[2.1, 2.2, 9.5, 2.1], [2.1, 2.2, 2.4, 2.2], [2.1, 2.2, 2.1, 4.2]] > > sorts to > > [[2.1, 2.2, 2.1, 4.2],[2.1, 2.2, 2.4, 2.2],[2.1, 2.2, 9.5, 2.1]] > > rather than > > [[2.1, 2.2, 9.5, 2.1], [2.1, 2.2, 2.4, 2.2], [2.1, 2.2, 2.1, 4.2]] > > thanks > > Pete a = "{{2.1, 2.2, 9.5, 2.1}, {2.1, 2.2, 2.4, 2.2}, {2.1, 2.2, 2.1, 4.2}}"\ [2..-3].split( '}, {' ).map{|x| x.split( /,\s+/ ).map{|s| s.to_f } } p a.sort