From: Piotr Szotkowski Date: 2010-11-08T18:26:41+09:00 Subject: Re: sort_by is not stable ? --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Robert Klemme: > You can either do > x.sort_by {|let,dig| [dig, let]} > or, if you don't want to create all those temporary arrays > x.sort {|(la,da),(lb,db)| da =3D=3D db ? la <=3D> lb : da <=3D> db} > x.sort {|(la,da),(lb,db)| c =3D da <=3D> db; c =3D=3D 0 ? la <=3D> lb : c} Or use #nonzero? and #<=3D> chaining like this: x.sort { |(la, da), (lb, db)| (da <=3D> db).nonzero? or la <=3D> lb } =E2=80=94 Piotr Szotkowski --=20 Language designers in general: You are IN THE WAY. Go here: http://rebol.com/oneliners.html then do us all a favor and don=E2=80=99t resist the urge to fall on that wakizashi when your shame overcomes you. [Jeff Bone] --fdj2RfSjLxBAspz7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkzXwkkACgkQi/mCfdEo8UqVBwCdGwezBNjOhAEgtBm3DCPjiUYp UVwAnj7MjDa9Ozlwf4O8eulyhcF6l8pE =ntG5 -----END PGP SIGNATURE----- --fdj2RfSjLxBAspz7--