. , , map . , :
my $hash = {
foo => { order => 3 },
bar => { order => 20 },
baz => { order => 66 },
};
"" . , $perfect_insert_sort, 67 ( 3, 20 66), undef .
. - , , .
@downvoter:
, , . . - .
:
- ( )
- An output is a rearrangement or reordering of input.
Part 2, of course, is being implemented: the hash structure is being converted to a list. However, part 1 is not fulfilled. The determination of the order does not occur. When pasting, the order was predefined. If it were a sort, then there would also be the following:
my @data = ... ;
my $index = -1;
my %stored = map { ++$index; $_ => { order => $index } } @data;
my @remade_data;
@remade_data[(map { $stored{$_}{order} } keys %stored)] = keys %stored;
As you can see, sorting does not occur in this piece of code, just a conversion.
source
share