|
2 | 2 | from typing import List
|
3 | 3 |
|
4 | 4 | from ._bubble_sort import BubbleSort
|
| 5 | +from ._merge_sort import RecursiveMergeSort |
5 | 6 | from .sort import Sort
|
6 | 7 |
|
7 | 8 | __all__ = [
|
8 | 9 | 'new_bubble_sort',
|
| 10 | + 'new_merge_sort', |
9 | 11 | 'Sort'
|
10 | 12 | ]
|
11 | 13 |
|
12 | 14 |
|
13 | 15 | def new_bubble_sort() -> Callable[[List[int]], List[int]]:
|
14 | 16 | """
|
15 |
| - Factory method to return function to sort |
| 17 | + Factory method to return sort function |
| 18 | +
|
| 19 | + >>> from py_algorithms.sort import new_merge_sort |
| 20 | + >>> |
| 21 | + >>> xs = [0, 6, 7, 8, 9, 4, 5, 12, -112] |
| 22 | + >>> sorting_algorithm = new_bubble_sort() |
| 23 | + >>> sorting_algorithm(xs) #=> [-112, 0, 4, 5, 6, 7, 8, 9, 12] |
| 24 | +
|
| 25 | + :return: a function1 interface to apply |
| 26 | + """ |
| 27 | + return lambda xs: BubbleSort().sort(xs) |
| 28 | + |
| 29 | + |
| 30 | +def new_merge_sort() -> Callable[[List[int]], List[int]]: |
| 31 | + """ |
| 32 | + Factory method to return sort function |
| 33 | +
|
| 34 | + >>> from py_algorithms.sort import new_merge_sort |
| 35 | + >>> |
| 36 | + >>> xs = [0, 6, 7, 8, 9, 4, 5, 12, -1] |
| 37 | + >>> sorting_algorithm = new_merge_sort() |
| 38 | + >>> sorting_algorithm(xs) #=> [-1, 0, 4, 5, 6, 7, 8, 9, 12] |
| 39 | +
|
16 | 40 | :return: a function1 interface to apply
|
17 | 41 | """
|
18 |
| - return lambda xs: BubbleSort().sort(xs) |
| 42 | + return lambda xs: RecursiveMergeSort().sort(xs) |
0 commit comments