Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/adrfer/Sort

Alluring experiments with sorting algorithms, sort of
https://github.com/adrfer/Sort

playground swift

Last synced: 2 months ago
JSON representation

Alluring experiments with sorting algorithms, sort of

Lists

README

        

# Sort
Alluring experiments with sorting algorithms, sort of.

Tested against `Swift 3` and `Xcode 8`.

##
### Welcome to the Sort Playground!

This is about exploring alternative implementations of different sorting techniques written in [Swift](http://swift.org). To move from disarray to order when managing collections of data, some variations of these sorting algorithms are provided, starting with a classic implementation that is then forged over and over until it becomes more idiomatic, or simply, more Swift-y.

Indulge yourself with the following takes:

- **The Classic:** a die-hard style, rooted in tradition, in all its imperative glory
- **The Swift-ish:** a sligthly more modern take on the classic, but still not quite quaint enough
- **The Swiftest:** a nifty approach that attempts to tap into the most powerful features of the language yet
- **The Generic:** a play on the swiftest version, but elevated to a type-agnostic nirvana status
- **The Functional:** a quirky take that unleashes some of the neat declarative aspects of the language
- **The Bonus:** a twist on both the swift-ish and generic versions that takes an ordering predicate

Also, a few test cases covering some initial conditions are included:

- Sorted
- Nearly Sorted
- Reversed
- Shuffled

I know, I know... Talk is cheap, show me the code, right?

##
### Table of Contents

- [Bubble Sort](https://github.com/adrfer/Sort/blob/master/Sort.playground/Pages/Bubble%20Sort.xcplaygroundpage/Contents.swift)
- [Insertion Sort](https://github.com/adrfer/Sort/blob/master/Sort.playground/Pages/Insertion%20Sort.xcplaygroundpage/Contents.swift)
- [Merge Sort](https://github.com/adrfer/Sort/blob/master/Sort.playground/Pages/Merge%20Sort.xcplaygroundpage/Contents.swift)
- [Quick Sort](https://github.com/adrfer/Sort/blob/master/Sort.playground/Pages/Quick%20Sort.xcplaygroundpage/Contents.swift)
- [Selection Sort](https://github.com/adrfer/Sort/blob/master/Sort.playground/Pages/Selection%20Sort.xcplaygroundpage/Contents.swift)

##

**Note:** Remember, the focus of this playground is experimentation, learning, and having fun. Do not expect any crazy award-winning performant code ahead, ok?

##
Feel free to [ping me](https://twitter.com/_adrfer) on Twitter.