$cmp = sub { ... }; # where $a/$b = [$k, $v]
$oh->sort( $comparator );
Or should users just create sorted copies with clone and
their own list of keys?
If adding a sort, should it optionally take Schwartzian
tranform arguments for efficiency/utility?
$oh->sort( $cmp, $xin, $xout );
Essentially, default $xin and $xout are these:
$xin = sub { [ $_, $_[0]->{$_} ] };
$xout = sub { $_->[0] };
Called like this:
@keys = map { $xout->($self) } sort $cmp map { $xin->($self) };
This might be a lot more complexity and indirection vs just using clone:
$oh = $oh->clone( map { ... } sort { ... } map { ... } $oh->keys );
So maybe not allowing custom $xin and $xout is best, but do a ST internally
to [$k, $v] for a bit of flexibility in ordering.
Or should users just create sorted copies with
cloneandtheir own list of keys?
If adding a sort, should it optionally take Schwartzian
tranform arguments for efficiency/utility?
Essentially, default
$xinand$xoutare these:Called like this:
This might be a lot more complexity and indirection vs just using clone:
So maybe not allowing custom $xin and $xout is best, but do a ST internally
to
[$k, $v]for a bit of flexibility in ordering.