         self.fieldTypeisArray = self.mode != nil
     }
     
+    public func encode(to encoder: Encoder) throws {
+        var container = encoder.container(keyedBy: CodingKeys.self)
+        if self.fieldTypeisArray {
+            var nested = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .key(named: self.field))
+            try nested.encode(self.sortOrder, forKey: .key(named: Sort.ORDER))
+            try nested.encode(self.mode, forKey: .key(named: Sort.MODE))
+        } else {
+            try container.encode(self.sortOrder, forKey: .key(named: self.field))
+        }
+    }
     
     private struct CodingKeys: CodingKey {
         var stringValue: String

                ]]
    }
    
    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        if self.fieldTypeisArray {
            var nested = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .key(named: self.field))
            try nested.encode(self.sortOrder, forKey: .key(named: Sort.ORDER))
            try nested.encode(self.mode, forKey: .key(named: Sort.MODE))
        } else {
            try container.encode(self.sortOrder, forKey: .key(named: self.field))
        }
    }
    
    required public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        let dic = try container.decode([String: CodableValue].self)
        let item = dic.first!

    func build() -> Sort
}

public struct Sort {
    
    private static let ORDER = "order"
    private static let MODE = "mode"
