Last active
February 1, 2024 21:31
-
-
Save ilyamon/bf87164919655817e912c73422753a22 to your computer and use it in GitHub Desktop.
Алгоритм сортування бульбашкою / bubble sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
for ($i = 0; $i < count($arr); $i++) { | |
for ($j = $i + 1; $j < count($arr); $j++) { | |
if ($arr[$i] > $arr[$j]) { | |
[$arr[$i], $arr[$j]] = [$arr[$j], $arr[$i]]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment