Skip to content
Alluring experiments with sorting algorithms, sort of
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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. 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

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.

You can’t perform that action at this time.