             box.group("all") { all in
                 
                 all.get() { request in
-                    let boxes = try Box.query().all()
+                    let boxes = try Box.query().sort(request.sort()).all()
                     return try Node.array(boxes.map(createNode(forBox:)))
                 }
                 

    var name: String {
        switch self {
        case .alphabetical:
            return "alphabetical"
        case .price:
            return "price"
        case .new:


extension QueryRepresentable {
    
    func sort(_ boxSort: BoxSorting?) throws -> Query<T> {
        if let sort = boxSort {
            return try self.sort(sort.field, sort.direction)
        }
        
        return try self.makeQuery()
    }
}

fileprivate extension Request {
    
    func sort() throws -> BoxSorting? {
        guard let sortParameter = self.headers["sort"]?.string else {
            return nil
        }
    
        return try BoxSorting.sortingType(forString: sortParameter)
    }
}

