From: michael libby Date: 2002-10-22T20:49:21+09:00 Subject: Re: Sort::Versions (was Re: Perl multiple match RE in Ruby?) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 22 October 2002 05:02, Nikodemus Siivola wrote: > Why define your own sort, when you can just pass the comparison method > to normal sort-method? (I may be missing something here, though.) I guess because it makes a convenient wrapper? > Second, modules might fit the bill better than classes. [snip] They certainly would the way I had it. Your suggestions give a lot of food for thought. My natural tendency is to want the version_cmp method in String and version_sort in Array... would it make more sense to simply do: class String def version_cmp(b) #compare(self,b) end end class Array def version_sort self.sort{|a,b| a.to_s.version_cmp(b.to_s)} end end That would save the step of extending those classes in code. -michael Michael C. Libby x@ichimunki.com http://www.ichimunki.com/ http://www.ichimunki.com/public_key.txt -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9tTsY4ClW9KMwqnMRAmGaAJ9/d3NTYMZDuMAtpdHqlOpXfzK0IwCfZBrs M39aqSiikTX4NagPEFUByqo= =/RGS -----END PGP SIGNATURE-----