|
1 | 1 | # Examples
|
2 | 2 | ```js
|
3 |
| -import array from "@aureooms/js-array" ; |
4 |
| -import search from "@aureooms/js-search" ; |
5 |
| -import compare from "@aureooms/js-compare" ; |
6 |
| - |
7 |
| -let fordjohnson = function ( compare , a , i , j ) { |
8 |
| - |
9 |
| - sort._fordjohnson( search.binarysearch )( compare , array.swap , a , i , j ) ; |
10 |
| - |
11 |
| -} ; |
| 3 | +import * as sort from "@aureooms/js-sort" ; |
| 4 | +import {increasing, decreasing} from "@aureooms/js-compare" ; |
12 | 5 |
|
13 | 6 | let a = [ 1 , 6 , 5 , 3 , 2 , 4 ] ;
|
| 7 | +let {selectionsort, isSorted} = sort; |
14 | 8 |
|
15 |
| -fordjohnson( compare.increasing , a , 0 , a.length ) ; |
| 9 | +selectionsort( increasing , a , 0 , a.length ) ; |
16 | 10 |
|
17 | 11 | a ; // [ 1 , 2 , 3 , 4 , 5 , 6 ]
|
| 12 | +isSorted(increasing, a, 0, a.length); // true |
18 | 13 |
|
19 |
| -fordjohnson( compare.decreasing , a , 0 , a.length ) ; |
| 14 | +selectionsort( decreasing , a , 0 , a.length ) ; |
20 | 15 |
|
21 | 16 | a ; // [ 6 , 5 , 4 , 3 , 2 , 1 ]
|
| 17 | +isSorted(decreasing, a, 0, a.length); // true |
22 | 18 |
|
23 | 19 | // but also
|
24 | 20 |
|
25 |
| -/** selectionsort */ |
26 |
| -let selectionsort = sort.selectionsort ; |
27 | 21 | /** bubblesort */
|
28 |
| -let bubblesort = sort.bubblesort ; |
| 22 | +let {bubblesort} = sort ; |
29 | 23 | ```
|
0 commit comments