Skip to content

๐Ÿ›‚ Swift array sort algorithm implementation.

License

Notifications You must be signed in to change notification settings

Meniny/SortAlgorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


Version Author Build Passing Swift
Platforms MIT
Cocoapods Carthage SPM

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

pod 'SortAlgorithm'

Contribution

You are welcome to fork and submit pull requests.

License

SortAlgorithm is open-sourced software, licensed under the MIT license.

Sample

// Randome Array
let original = [Int].init(repeating: 0, count: 5000).map { $0 + Int(arc4random_uniform(5000)) }
let closure: Array<Int>.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))")

About

๐Ÿ›‚ Swift array sort algorithm implementation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published