// Order works exactly like Query.Order. See the documentation for Query.Order
// for a full description.
19948
func (q *TransactionQuery) Order(fieldName string) *TransactionQuery {
	q.query.Order(fieldName)
	return q
}
774338
func (node *Select) AddOrder(order *Order) {
	node.OrderBy = append(node.OrderBy, order)
}
1089700
func (p *queryPlan) orderBy() {
	order := p.stm.OrderByConfig()
	if len(order) <= 0 {
		return
	}
	tracer.Trace(p.tracer, func() []string {
		return []string{"Ordering by " + order.String()}
	})
	p.tbl.Sort(order)
}
130644
func Ordered(platforms ...specs.Platform) MatchComparer {
	matchers := make([]Matcher, len(platforms))
	for i := range platforms {
		matchers[i] = NewMatcher(platforms[i])
	}
	return orderedPlatformComparer{
		matchers: matchers,
	}
}
1299966
func (s *SearchSource) Sort(field string, ascending bool) *SearchSource {
	s.sorters = append(s.sorters, SortInfo{Field: field, Ascending: ascending})
	return s
}
741728
func (d *LogDatastore) Query(q dsq.Query) (dsq.Results, error) {
	log.Printf("%s: Query\n", d.Name)
	log.Printf("%s: q.Prefix: %s\n", d.Name, q.Prefix)
	log.Printf("%s: q.KeysOnly: %v\n", d.Name, q.KeysOnly)
	log.Printf("%s: q.Filters: %d\n", d.Name, len(q.Filters))
	log.Printf("%s: q.Orders: %d\n", d.Name, len(q.Orders))
	log.Printf("%s: q.Offset: %d\n", d.Name, q.Offset)

	return d.child.Query(q)
}
1252117
func order(order string) scope {
	return scopeFunc(func(db *gorm.DB) *gorm.DB {
		return db.Order(order)
	})
}
243195
func (node *Union) AddOrder(order *Order) {
	node.OrderBy = append(node.OrderBy, order)
}
266336
func (mbc *Receiver) Ordered(env *cb.Envelope) ([][]*cb.Envelope, bool) {
	defer func() {
		<-mbc.Block
	}()

	mbc.mutex.Lock()
	defer mbc.mutex.Unlock()

	if mbc.IsolatedTx {
		logger.Debugf("Receiver: Returning dual batch")
		res := [][]*cb.Envelope{mbc.curBatch, {env}}
		mbc.curBatch = nil
		return res, false
	}

	if mbc.CutAncestors {
		logger.Debugf("Receiver: Returning current batch and appending newest env")
		res := [][]*cb.Envelope{mbc.curBatch}
		mbc.curBatch = []*cb.Envelope{env}
		return res, true
	}

	if !mbc.SkipAppendCurBatch {
		mbc.curBatch = append(mbc.curBatch, env)
	}

	if mbc.CutNext {
		logger.Debugf("Receiver: Returning regular batch")
		res := [][]*cb.Envelope{mbc.curBatch}
		mbc.curBatch = nil
		return res, false
	}

	logger.Debugf("Appending to batch")
	return nil, true
}
975169
func (q *QueryString) SortOrder(name string) (os []*SortOrder, err error) {
	defer func() {
		if rec := recover(); rec != nil {
			err = rec.(error)
		}
	}()

	raw, ok := q.fields[name]
	if !ok {
		return nil, fmt.Errorf("field not found: %q", name)
	}

	os, raw = parseSortOrders(raw)
	if len(raw) != 0 {
		os = nil
		err = UnexpectedEndOfSortOrders
	}

	return
}
1350895
func (r *ReindexSource) Sort(field string, ascending bool) *ReindexSource {
	r.request = r.request.Sort(field, ascending)
	return r
}
603159
func (q *Query) OrderExpr(order string, params ...interface{}) *Query {
	if order != "" {
		q.order = append(q.order, &queryParamsAppender{order, params})
	}
	return q
}
240083
func (a *CompositeAggregationDateHistogramValuesSource) Order(order string) *CompositeAggregationDateHistogramValuesSource {
	a.order = order
	return a
}
1345646
func Query(q string) func(r *Rego) {
	return func(r *Rego) {
		r.query = q
	}
}
880743
func (b *UpdateBuilder) OrderBy(exprs ...interface{}) *UpdateBuilder {
	b.Update.OrderBy = makeOrderBy(exprs...)
	return b
}
1339233
func (c *Client) GetOrder(orderID string) (*Order, error) {
	order := &Order{}

	req, err := c.NewRequest("GET", fmt.Sprintf("%s%s%s", c.APIBase, "/v2/checkout/orders/", orderID), nil)
	if err != nil {
		return order, err
	}

	if err = c.SendWithAuth(req, order); err != nil {
		return order, err
	}

	return order, nil
}
1266194
func (ctrl Controller) Orders(w http.ResponseWriter, req *http.Request) {
	var (
		Orders      []orders.Order
		currentUser = utils.GetCurrentUser(req)
		tx          = utils.GetDB(req)
	)

	tx.Preload("OrderItems").Where("state <> ? AND state != ?", orders.DraftState, "").Where(&orders.Order{UserID: &currentUser.ID}).Find(&Orders)

	ctrl.View.Execute("orders", map[string]interface{}{"Orders": Orders}, req, w)
}