Swiftpack.co - Package - lukaskubanek/OrderedDictionary

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


Ordered dictionary data structure implementation in Swift


Swift 4.2+ Swift Package Manager Carthage License: MIT Twitter: @lukaskubanek

OrderedDictionary is a lightweight implementation of an ordered dictionary data structure in Swift.

The OrderedDictionary struct is a generic collection that combines the features of Dictionary and Array data structures from the Swift standard library. Like Dictionary, it stores key-value pairs with each key being unique and maps each key to an associated value. Like Array, it stores those pairs sorted and accessible by a zero-based integer index.

OrderedDictionary provides similar APIs to collections in the Swift standard library like accessing contents by keys or indices, inserting and removing elements, iterating, sorting, filtering, etc.

Internally, OrderedDictionary uses a backing storage composed of a Dictionary for storing the key-value pairs and an Array for managing the ordered keys. This architecture makes it not the most pefromant implementation possible, but it gets its job done while reusing most functionality from the Swift standard library.


  • Swift 4.2+
  • Xcode 10.0+
  • iOS 8.0+ / macOS 10.10+

For support of Swift 4.0 and 4.1 please refer to version 2.x of this library. The Xcode and OS requirements apply only when the library is integrated as a framework or via the Xcode project.


Swift Package Manager

To install OrderedDictionary using the Swift Package Manager, add it as a dependency into your Package.swift file:

let package = Package(
    dependencies: [
        .package(url: "https://github.com/lukaskubanek/OrderedDictionary.git", from: "3.0.1")


To install OrderedDictionary using Carthage, add it as a dependency into your Cartfile:

github "lukaskubanek/LoremSwiftum"

Then drag either the OrderedDictionary.xcodeproj or the OrderedDictionary.framework into your Xcode project/workspace and link your target against the OrderedDictionary.framework. Make sure that the framework gets copied to your application bundle.

Git Submodules

You can also install OrderedDictionary via Git submodules and integrate the project OrderedDictionary.xcodeproj from the submodule directly into your Xcode workspace.

⚠️ Note About CocoaPods

Although there has been a high demand for CocoaPods support, this distribution method won't be officially supported by this library. If you really want to integrate this library via CocoaPods, you can create and maintain a custom podspec (see the last section of this post).

Usage & Docs

For the usage of this library please refer to the example playground. For documentation please refer to the documentation comments.


Stars: 171
Last commit: 2 weeks ago

Related Packages


3.0.1: Xcode Project Fix - 2020-05-28T09:17:08

Re-added marketing version to the Xcode project as it’s used in a required key within the Info.plist (#62).