// WithPaginationSort set to true, the results of a non-paginated query will return sorted from Riak
431437
func (builder *SecondaryIndexQueryCommandBuilder) WithPaginationSort(paginationSort bool) *SecondaryIndexQueryCommandBuilder {
	builder.protobuf.PaginationSort = &paginationSort
	return builder
}
309995
func (o *ListTasksParams) WithPageSize(pageSize *int32) *ListTasksParams {
	o.SetPageSize(pageSize)
	return o
}
328397
func restAddPort(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
	glog.V(1).Infof("Add PORT with %s %#v", r.URL.Path, r)

	serviceid, application, port, err := getPortContext(r)
	if err != nil {
		err := fmt.Errorf("Error removing port from service (%s): %v", serviceid, err)
		glog.Error(err)
		restServerError(w, err)
		return
	}

	var request endpointRequest
	err = r.DecodeJsonPayload(&request)
	if err != nil {
		restBadRequest(w, err)
		return
	}

	glog.V(0).Infof("Add PORT with %s %#v", r.URL.Path, r)

	facade := ctx.getFacade()
	dataCtx := ctx.getDatastoreContext()

	_, err = facade.AddPublicEndpointPort(dataCtx, serviceid, application,
		port, request.UseTLS, request.Protocol, true, true)
	if err != nil {
		glog.Errorf("Error adding port to service (%s): %v", request.ServiceName, err)
		restServerError(w, err)
		return
	}

	glog.V(2).Infof("Port (%s) added to service (%s), UseTLS=%s, protocol=%s",
		port, request.ServiceName, request.UseTLS, request.Protocol)

	restSuccess(w)
}
448773
func (s *Site) renderPaginator(p *pageState, layouts []string) error {

	paginatePath := s.Cfg.GetString("paginatePath")

	d := p.targetPathDescriptor
	f := p.s.rc.Format
	d.Type = f

	if p.paginator.current == nil || p.paginator.current != p.paginator.current.First() {
		panic(fmt.Sprintf("invalid paginator state for %q", p.pathOrTitle()))
	}

	// Write alias for page 1
	d.Addends = fmt.Sprintf("/%s/%d", paginatePath, 1)
	targetPaths := page.CreateTargetPaths(d)

	if err := s.writeDestAlias(targetPaths.TargetFilename, p.Permalink(), f, nil); err != nil {
		return err
	}

	// Render pages for the rest
	for current := p.paginator.current.Next(); current != nil; current = current.Next() {

		p.paginator.current = current
		d.Addends = fmt.Sprintf("/%s/%d", paginatePath, current.PageNumber())
		targetPaths := page.CreateTargetPaths(d)

		if err := s.renderAndWritePage(
			&s.PathSpec.ProcessingStats.PaginatorPages,
			p.Title(),
			targetPaths.TargetFilename, p, layouts...); err != nil {
			return err
		}

	}

	return nil
}
444609
func (b *batch) RequestSort() bool {
	if b == deletedChildBatchMarker {
		return true
	}

	// false because we must never wait for sorter else it can deadlock.
	sorted := b.segment.RequestSort(false)

	for _, childBatch := range b.childBatches {
		sorted = childBatch.RequestSort() && sorted
	}

	return sorted
}
177884
func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
	ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
	defer cancel()

	client.PaginateWithContext(ctx, g, callback)
}
1289996
func (by pageBy) Sort(pages Pages) {
	ps := &pageSorter{
		pages: pages,
		by:    by, // The Sort method's receiver is the function (closure) that defines the sort order.
	}
	sort.Stable(ps)
}
630205
func CombinePortRanges(ranges ...PortRange) []PortRange {
	SortPortRanges(ranges)
	var result []PortRange
	var current *PortRange
	for _, pr := range ranges {
		thispr := pr
		if current == nil {
			current = &thispr
			continue
		}
		if pr.Protocol == current.Protocol && pr.FromPort == current.ToPort+1 {
			current.ToPort = thispr.ToPort
			continue
		}
		result = append(result, *current)
		current = &thispr
	}
	if current != nil {
		result = append(result, *current)
	}
	return result
}
999365
func (self *Query) Sort(fields ...string) *Query {

	self.sort = append(self.sort, fields...)

	return self
}
643552
func (q Query) CountWith(predicate func(interface{}) bool) (r int) {
	next := q.Iterate()

	for item, ok := next(); ok; item, ok = next() {
		if predicate(item) {
			r++
		}
	}

	return
}
1309170
func (r Route) ValidateWithRandomPort(randomPort bool) error {
	if r.Domain.IsHTTP() && randomPort {
		return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name}
	}

	if r.Domain.IsTCP() && !r.Port.IsSet && !randomPort {
		return actionerror.TCPRouteOptionsNotProvidedError{}
	}
	return r.Validate()
}
244756
func (s *ListTaskDefinitionsInput) SetSort(v string) *ListTaskDefinitionsInput {
	s.Sort = &v
	return s
}
457401
func (c *Client) APIHostPorts() ([][]network.HostPort, error) {
	var result params.APIHostPortsResult
	if err := c.facade.FacadeCall("APIHostPorts", nil, &result); err != nil {
		return nil, err
	}
	return result.NetworkHostsPorts(), nil
}
1295732
func (a *APIAddresser) APIHostPorts() ([][]network.HostPort, error) {
	var result params.APIHostPortsResult
	err := a.facade.FacadeCall("APIHostPorts", nil, &result)
	if err != nil {
		return nil, err
	}
	return result.NetworkHostsPorts(), nil
}
213884
func (s *CatAliasesService) Sort(fields ...string) *CatAliasesService {
	s.sort = fields
	return s
}
1278040
func (nsPayloads_) orderedResults(docs []payloadDoc, names []string) []payload.Result {
	found := make(map[string]payloadDoc)
	for _, doc := range docs {
		found[doc.Name] = doc
	}
	results := make([]payload.Result, len(names))
	for i, name := range names {
		results[i].ID = name
		if doc, ok := found[name]; ok {
			full := nsPayloads.asPayload(doc)
			results[i].Payload = &full
		} else {
			results[i].NotFound = true
			results[i].Error = errors.NotFoundf(name)
		}
	}
	return results
}
880221
func (s *ScanService) SortWithInfo(info SortInfo) *ScanService {
	s.searchSource = s.searchSource.SortWithInfo(info)
	return s
}