Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] [Javascript] Shouldn't there be a sort option on objects



On 7 February 2011 09:55, Raymond Wan <rwan.kyoto@example.com> wrote:

> Perhaps languages like Perl and Python can [sort arbitrary lists of objects]

Sure. Here's how to sort arrays of hashes in Perl and Ruby:

Perl:

@array = sort { $a{some_key} <=> $b{some_key} } @array;

Ruby:

array.sort! {|a, b| a['some_key'] <=> b['some_key'] }

-- 
Cheers,
Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links