in reply to Re^3: RFC:A brief tutorial on Perl's native sorting facilities.
in thread RFC:A brief tutorial on Perl's native sorting facilities.
That's not always possible. Eg. if it's a list of objects ...
If the data is a list of objects to be sorted
And if that is the case, then each pair of objects would need to be compared using that overloaded operator and there would be no benefit from using any of the indirect sorting methods.
In which case, the GRT would work just fine; avoid the creation of the keys array and the slice operation. That means the GRT would avoid the creation of several intermediate arrays and lists. It also avoids the callback into Perl code (it's main strength, and the reason for its performance), and so will normally be faster.
And even if it's just a list of references to some data structures, by serialization and deserialization you end up with copies of the data structures.
I do not understand what you mean by this? In particular, the GRT never requires the keys to be "deserialised".
Whatever you put into the @keys array, has later to be compared using one of the standard comparison operators. With that being the case, using the GRT again avoids the need for callbacks and will be faster.
I realise that I am probably missing something here, but do you have any practical examples of when this indexed sort method with outperform a GRT?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: RFC:A brief tutorial on Perl's native sorting facilities.
by Jenda (Abbot) on Feb 06, 2007 at 22:02 UTC | |
by jdporter (Paladin) on Feb 06, 2007 at 22:27 UTC | |
by Jenda (Abbot) on Feb 06, 2007 at 22:39 UTC | |
by BrowserUk (Patriarch) on Feb 07, 2007 at 00:36 UTC | |
by jdporter (Paladin) on Feb 07, 2007 at 01:19 UTC |