Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 07435ad

Browse files
committed
1.0.0
1 parent 8159640 commit 07435ad

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,25 @@ You are welcome to fork and submit pull requests.
4545
## License
4646

4747
`SortAlgorithm` is open-sourced software, licensed under the `MIT` license.
48+
49+
## Sample
50+
51+
```swift
52+
// Randome Array
53+
let original = [Int].init(repeating: 0, count: 5000).map { 0ドル + Int(arc4random_uniform(5000)) }
54+
let closure: Array<Int>.SortingCompareClosure = { (l, r) -> Bool in
55+
return l < r
56+
}
57+
// Now sort
58+
print("Bubble: \n\(original.bubbleSort(by: closure))")
59+
print("\n\n======\n\n")
60+
print("Insertion: \n\(original.insertionSort(by: closure))")
61+
print("\n\n======\n\n")
62+
print("Merge: \n\(original.mergeSort(by: closure))")
63+
print("\n\n======\n\n")
64+
print("Quick: \n\(original.quickSort(by: closure))")
65+
print("\n\n======\n\n")
66+
print("Counting: \n\(original.countingSort())")
67+
print("\n\n======\n\n")
68+
print("Heap: \n\(original.heapSort(by: closure))")
69+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /