Article View: pl.comp.lang.ruby
Article #1209Re: rozrzucić
From: Radosław Bułat
Date: Wed, 18 Feb 2009 11:22
Date: Wed, 18 Feb 2009 11:22
17 lines
1161 bytes
1161 bytes
Od Bronisław Tatul pisze:
> Mam pytanie. Jak rozrzucic losowo elementy w tablicy. Chodzi mi o coś
> odwrotnego do sortowania.
Od wersji 1.8.7:
arr = (1..10).to_a
arr.shuffle!
Wcześniej:
arr = (1..10).to_a
arr = arr.sort_by { rand }
--
Radosław Bułat
http://radarek.jogger.pl - mój blog
Technical Details
Message-ID:
<gngr0v$eu$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<gngc3r$t4t$1@atlantis.news.neostrada.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Radosław Bułat <radarrek@poczta.fm> Newsgroups: pl.comp.lang.ruby Subject: Re: rozrzucić Date: Wed, 18 Feb 2009 12:22:07 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 17 Message-ID: <gngr0v$eu$1@inews.gazeta.pl> References: <gngc3r$t4t$1@atlantis.news.neostrada.pl> NNTP-Posting-Host: chello089074175199.chello.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1234956128 478 89.74.175.199 (18 Feb 2009 11:22:08 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 18 Feb 2009 11:22:08 +0000 (UTC) X-User: radek.bulat In-Reply-To: <gngc3r$t4t$1@atlantis.news.neostrada.pl> User-Agent: Thunderbird 2.0.0.19 (X11/20090105) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit