in reply to How to perform different sorts on multiple sections of items in the same array
Very-elaborate sorting requirements such as these can be satisfied by creating an appropriate function for use with the sort verb. As you know, this function must return a value that is either less-than, equal-to, or greater-than zero, based on its comparison of two strings ($a and $b) that are presented to it. Typically, this is an “in-line” function such as { $a <=> $b } (using an operator that is expressly designed for this purpose), but it does not have to be. You can write an entirely separate sub and refer to it within the sort verb, and this is what I suggest that you do.
Let me describe my notion just in words. This is what the sub will do, each time it is called.
Notice that you are not splitting the array and sorting each piece. You are not using memory-hungry exotica like Schwartz. This notion can be applied to sorts of any size, and it applies equally well to both in-memory and disk-based sorts.
Q.E.D.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to perform different sorts on multiple sections of items in the same array
by Anonymous Monk on Dec 29, 2014 at 12:49 UTC | |
|
Re^2: How to perform different sorts on multiple sections of items in the same array
by karlgoethebier (Abbot) on Dec 29, 2014 at 13:04 UTC | |
|
Re^2: How to perform different sorts on multiple sections of items in the same array
by Anonymous Monk on Dec 29, 2014 at 19:01 UTC | |
|
Re^2: How to perform different sorts on multiple sections of items in the same array
by Laurent_R (Canon) on Dec 29, 2014 at 19:52 UTC | |
by locked_user sundialsvc4 (Abbot) on Dec 30, 2014 at 02:43 UTC |