Skip to content

Commit 9d76224

Browse files
authored
Merge pull request #22 from titsuki/fix-sort
Use .map(&f1).sort(&f2).map(&f3) instead of .sort(&f4)
2 parents b21953f + 0265e86 commit 9d76224

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Algorithm/LibSVM.pm6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ method !_load-problem(\lines) {
6666
my @feature-list = $features.split(/\s+/);
6767

6868
my $next = Algorithm::LibSVM::Node.new(index => -1, value => 0e0);
69-
for @feature-list>>.split(":", :skip-empty).sort({ $^b[0] <=> $^a[0] }) -> ($index, $value) {
69+
for @feature-list>>.split(":", :skip-empty).map({ .[0] => .[1] }).sort(-*.key).map({ .key, .value }) -> ($index, $value) {
7070
$!nr-feature = ($!nr-feature, $index.Int).max;
7171
$next = Algorithm::LibSVM::Node.new(index => $index.Int, value => $value.Num, next => $next);
7272
}

0 commit comments

Comments
 (0)