From: "Haris Bogdanović" Date: 2009-07-12T01:30:12+09:00 Subject: Re: one line sorting Well, I saw one line Haskell sort and thought, maybe it's possible in Ruby. I'm just trying out functional programming in Ruby. Could you just tell me how to do methods on my expression which has block {} and evaluates to number object; do I put () parenthesses around the whole expression and dot after them or somethin else ? Thanks "Fabian Streitel" wrote in message news:2569cf860907110914udbd2981w70e553eb6c74f492@mail.gmail.com... Well, you could just do [7,4,9,55,98,11,42].sort ;-) That's much more optimized than anything else you can do in one line... What you described is called a "Selection sort" ( http://en.wikipedia.org/wiki/Selection_sort) If you really must implement it yourself (why in one line?) You could try something like this: 0.upto(n.size-1) do |i| lowest_idx = i + n[i..-1].index(n[i..-1].min) n[lowest_idx], n[i] = n[i], n[lowest_idx] end Which is already pretty hackishly short and inefficient. ;-) Greetz!