Skip to content

Commit 56c68f6

Browse files
authored
Fix Buffertools::sort() ternary operation
Ternary operations are, different from other popular languages, left-associative in PHP. Thus the return value of this method was -1 when both binaries where equal.
1 parent c6c1eb2 commit 56c68f6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Buffertools/Buffertools.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static function sort(array $items, callable $convertToBuffer = null): arr
108108
usort($items, function ($a, $b) use ($convertToBuffer) {
109109
$av = $convertToBuffer($a)->getBinary();
110110
$bv = $convertToBuffer($b)->getBinary();
111-
return $av == $bv ? 0 : $av > $bv ? 1 : -1;
111+
return $av == $bv ? 0 : ($av > $bv ? 1 : -1);
112112
});
113113

114114
return $items;

0 commit comments

Comments
 (0)