From: Bulat Ziganshin Date: 2002-09-25T15:59:02+09:00 Subject: Re: are functions/methods "first class objects"? Hello GOTO, Wednesday, September 25, 2002, 9:30:40 AM, you wrote: GK> Ruby 1.7 has Array#sort_by. The above are written as: i know GK> def criteria(switch) GK> case switch GK> when "es" GK> Proc.new{|i| [File.extname(i), File.size(i)]} GK> when "n" GK> Proc.new{|i| File.basename(i).sub(/\.([^.]+)$/, "")} GK> else GK> Proc.new{|i| i} GK> end GK> end GK> puts Dir["*"].sort_by(&criteria("es")) hmm. you don't understand. sort string is a sequence of chars, which maps to sort criterions. this char may be e for extennsion n for filename w/o path/extension s for size g for group (one group is c sources, next - executables and so on) i for some intellectual THING :) i need to translate sequence of this chars to function which returns array with all the data for sort_by: sort_files "es" sort_files "en" sort_files "geis" and much more variants. so i need to construct closure on the fly -- Best regards, Bulat mailto:bulatz@integ.ru