Home >Web Front-end >JS Tutorial >JavaScript implementation of quick sort (written by myself)_Basic knowledge

JavaScript implementation of quick sort (written by myself)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:46:031045browse

Brief description:
Use JavaScript to sort a set of numbers. There is no direct number comparison function to call in js, so I wrote a quick sort
Knowledge points:
1. Regular expression to extract the string of positive and negative numbers
2. Convert str to number and put it back into the list
3. Declaration and definition of js object Sort class
4. Sort class constructor and member function definition Method (prototype)
5. Quick sort algorithm
Code:

Copy code Code As follows:


.

Quick Sort




Quick Sort










SORTED LIST:



Output:
JavaScript implementation of quick sort (written by myself)_Basic knowledge
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn