Alluring experiments with sorting algorithms, sort of.
Swift 3 and
Welcome to the Sort Playground!
This is about exploring alternative implementations of different sorting techniques written in Swift. 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:
- Nearly Sorted
I know, I know... Talk is cheap, show me the code, right?
Table of Contents
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 on Twitter.