     public func index(before i: Int) -> Int {
         assert(i > 0, "Cannot decrement index to \(i - 1)")
         return i - 1
+    }
+}
+
+extension SortedDictionary: RandomAccessCollection {
+
+    /// - Returns: Element at the given `index`.
+    public subscript (index: Int) -> (Key, Value) {
+        let key = keys[index]
+        let value = unsorted[key]!
+        return (key, value)
     }
 }
 

    public var endIndex: Int {
        return keys.count
    }

    /// - returns: Element at the given `index`.
    public subscript (index: Int) -> (Key, Value) {
        let key = keys[index]
        let value = unsorted[key]!
        return (key, value)
    }
}

extension SortedDictionary: BidirectionalCollection {

//  Created by James Bean on 12/23/16.
//
//

/// Ordered dictionary which has sorted `keys`.
public struct SortedDictionary<Key, Value>: DictionaryProtocol where Key: Hashable & Comparable {
