Hey again,
Incidently, remember that sortBy is slower than sort when you're working
on an array (which does have sort)... In short, it's just about
compacting slightly:
data.sort(function(a, b) {
// code that compares a.x with b.x somehow
});
with:
data.sortBy(function(a) {
// code that produces a.x
});
BUT sortBy will have to internally duplicate your enumerable to do its
work properly, AND will also call twice the amount of functions that
sort would call (it will call your callback on a and b instead of just
once with a and b as parameters). It's WAY less efficient.
So if you can go ahead and write your comparator function instead, by
all means use sort over sortBy when working on an array!
--
Christophe Porteneuve aka TDD
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---