Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meniny/sortalgorithm
🛂 Swift array sort algorithm implementation.
https://github.com/meniny/sortalgorithm
algorithm sort sort-algorithm swift
Last synced: about 1 month ago
JSON representation
🛂 Swift array sort algorithm implementation.
- Host: GitHub
- URL: https://github.com/meniny/sortalgorithm
- Owner: Meniny
- License: mit
- Created: 2018-01-08T02:49:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T04:19:02.000Z (over 5 years ago)
- Last Synced: 2024-09-18T06:12:47.860Z (about 2 months ago)
- Topics: algorithm, sort, sort-algorithm, swift
- Language: Swift
- Homepage:
- Size: 49.8 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Introduction
## What's this?
`SortAlgorithm` is a Swift array sort algorithm framework.
## Requirements
* iOS 8.0+
* tvOS 9.0+
* macOS 10.9+
* watchOS 2.0+
* Xcode 9 with Swift 5## Installation
#### CocoaPods
```ruby
pod 'SortAlgorithm'
```## Contribution
You are welcome to fork and submit pull requests.
## License
`SortAlgorithm` is open-sourced software, licensed under the `MIT` license.
## Sample
```swift
// Randome Array
let original = [Int].init(repeating: 0, count: 5000).map { $0 + Int(arc4random_uniform(5000)) }
let closure: Array.SortingCompareClosure = { (l, r) -> Bool in
return l < r
}
// Now sort
print("Bubble: \n\(original.bubbleSort(by: closure))")
print("\n\n======\n\n")
print("Insertion: \n\(original.insertionSort(by: closure))")
print("\n\n======\n\n")
print("Merge: \n\(original.mergeSort(by: closure))")
print("\n\n======\n\n")
print("Quick: \n\(original.quickSort(by: closure))")
print("\n\n======\n\n")
print("Counting: \n\(original.countingSort())")
print("\n\n======\n\n")
print("Heap: \n\(original.heapSort(by: closure))")
```