<?php function qsort(&$arr) { _quick_sort($arr, 0, count($arr) - 1); } function _quick_sort(&$arr, $low, $high) { $low_data = $arr[$low]; $prev_low = $low; $prev_high = $high; while ($low < $high) { while ($arr[$high] >= $low_data && $low < $high) { $high--; } if ($low < $high) { $arr[$low] = $arr[$high]; $low++; } while ($arr[$low] <= $low_data && $low < $high) { $low++; } if ($low < $high) { $arr[$high] = $arr[$low]; $high--; } }
Quick sort using recursive algorithm.
@param array $arr The array to be sorted
@param int $low The lowest sorting subsection
@param int $high The highest sorting field
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...
03 Jan 2025
Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...
27 Dec 2024
Executing Command Line Binaries in Node.jsExecuting third-party binaries is an essential task when porting CLI libraries from other languages to...
03 Dec 2024
Combining Static Libraries into One with CMakeWhen working with projects dependent on multiple static libraries, merging these libraries into a...
04 Dec 2024
Creating Shared Libraries in GoShared libraries, or dynamic link libraries (.so files), allow separate programs to share common code and data,...
13 Dec 2024
We upgrade our base framework to springboot 3.3.5 and other related libraries recently. A bug was reported to me during the testing. Some query would fail with JSqlParser 5.0. Here is a simple demonstration: public class Test { public static vo
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images