Skip to content

Commit 0aa2eb1

Browse files
author
Kapitanov Andrey
committed
V7 sort by array
1 parent b128904 commit 0aa2eb1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Concerns/ExtendsSort.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ public function sortByCustomArray(string $field, array $items): static
4343
$script = new Script(
4444
params: ['items' => $items],
4545
source: "
46-
int index = params['items'].length;
4746
for (int i = 0; i < params['items'].length; i++) {
4847
if (params['items'][i] == doc['{$field}'].value) {
49-
index = i;
50-
break;
48+
return i;
5149
}
5250
}
5351
54-
return index;
52+
return params['items'].length;
5553
",
5654
);
5755

0 commit comments

Comments
 (0)