HomeCurrent UR
|
Description General sorting macro Syntax PGsort( &sort_subroutine, @list); Params &sort_subroutine is a subroutine of two variables which defines order. It's output must be -1, 0, 1 depending on whether the first variable is less than, equal to or greater than the second. Returns Returns list of elements in @list, ignoring duplicates. The order is unspecified. Examples join(" ",PGsort( sub {$_[0] <=> $_[1]} , (23,2,10,11,11,31); ); returns "2 10 11 11 23 31" Notes Using the perl sort directly in problems is not allowed for two reasons. The first is that the hardwired $a and $b variables used by sort can interfere with other values assigned to $a and $b. The second is that it is pretty easy to create closed loops with sort that hang the program. Currently nothing is done to prevent this, but later we may wish to modify num_sort and lex_sort to catch this problem. See Also lex_sort Macro Definition File PGbasicmacros.pl
|
||
Last update: Wednesday, January 10, 2007 at 10:21:43 PM.
This site maintained using Manila and Frontier software. |
|||