Travis build: 425
This commit is contained in:
36
README.md
36
README.md
@ -249,6 +249,15 @@
|
||||
|
||||
</details>
|
||||
|
||||
### _Uncategorized_
|
||||
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`quickSort`](#quicksort)
|
||||
|
||||
</details>
|
||||
|
||||
## Adapter
|
||||
|
||||
### call
|
||||
@ -4002,6 +4011,33 @@ validateNumber('10'); // true
|
||||
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
## _Uncategorized_
|
||||
|
||||
### quickSort
|
||||
|
||||
QuickSort an Array (ascending sort by default).
|
||||
|
||||
Use recursion.
|
||||
Use `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it.
|
||||
If the parameter `desc` is truthy, return array sorts in descending order.
|
||||
|
||||
```js
|
||||
const quickSort = ([n, ...nums], desc) =>
|
||||
isNaN(n)
|
||||
? []
|
||||
: [
|
||||
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||
n,
|
||||
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
|
||||
];
|
||||
```
|
||||
|
||||
```js
|
||||
quickSort([4, 1, 3, 2]); // [1,2,3,4]
|
||||
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
@ -262,6 +262,9 @@
|
||||
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a>
|
||||
<a class="sublink-1" href="#validatenumber">validateNumber</a>
|
||||
|
||||
<h3>Uncategorized
|
||||
</h3><a class="sublink-1" href="#quicksort">quickSort</a>
|
||||
|
||||
</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height:100%;overflow-y:auto;background:#eceef2;padding:0"><a id="top"> </a><h2 style="text-align:center">Adapter</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="call">call</h3></div><div class="section double-padded">
|
||||
<p>Given a key and a set of arguments, call them when given a context. Primarily useful in composition.</p>
|
||||
@ -1776,6 +1779,24 @@ Use <code>Number()</code> to check if the coercion holds.</p>
|
||||
</code></pre>
|
||||
<pre><code class="language-js">validateNumber('10'); // true
|
||||
</code></pre>
|
||||
</div></div><br/><h2 style="text-align:center">Uncategorized</h2>
|
||||
<div class="card fluid"><div class="section double-padded"><h3 id="quicksort">quickSort</h3></div><div class="section double-padded">
|
||||
<p>QuickSort an Array (ascending sort by default).</p>
|
||||
<p>Use recursion.
|
||||
Use <code>Array.filter</code> and spread operator (<code>...</code>) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it.
|
||||
If the parameter <code>desc</code> is truthy, return array sorts in descending order.</p>
|
||||
<pre><code class="language-js">const quickSort = ([n, ...nums], desc) =>
|
||||
isNaN(n)
|
||||
? []
|
||||
: [
|
||||
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||
n,
|
||||
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
|
||||
];
|
||||
</code></pre>
|
||||
<pre><code class="language-js">quickSort([4, 1, 3, 2]); // [1,2,3,4]
|
||||
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
|
||||
</code></pre>
|
||||
</div></div><br/>
|
||||
<footer>
|
||||
<p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p>
|
||||
|
||||
@ -11,13 +11,13 @@ const quickSort = ([n, ...nums], desc) =>
|
||||
isNaN(n)
|
||||
? []
|
||||
: [
|
||||
...quickSort(nums.filter(v => desc ? v > n : v <= n), desc),
|
||||
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||
n,
|
||||
...quickSort(nums.filter(v =>!desc ? v > n : v <= n), desc)
|
||||
]
|
||||
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
|
||||
];
|
||||
```
|
||||
|
||||
```js
|
||||
quickSort([4,1,3,2,]); // [1,2,3,4]
|
||||
quickSort([4,1,3,2,],true); // [4,3,2,1]
|
||||
quickSort([4, 1, 3, 2]); // [1,2,3,4]
|
||||
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
|
||||
```
|
||||
|
||||
@ -94,6 +94,7 @@ promisify:adapter
|
||||
pull:array
|
||||
pullAtIndex:array
|
||||
pullAtValue:array
|
||||
quickSort:uncategorized
|
||||
randomHexColorCode:utility
|
||||
randomIntegerInRange:math
|
||||
randomNumberInRange:math
|
||||
|
||||
Reference in New Issue
Block a user