// NaiveOrder reorders results according to given orders.
// WARNING: this is the only non-stream friendly operation!
762295
func NaiveOrder(qr Results, orders ...Order) Results {
	// Short circuit.
	if len(orders) == 0 {
		return qr
	}

	return ResultsWithProcess(qr.Query(), func(worker goprocess.Process, out chan<- Result) {
		defer qr.Close()
		var entries []Entry
	collect:
		for {
			select {
			case <-worker.Closing():
				return
			case e, ok := <-qr.Next():
				if !ok {
					break collect
				}
				if e.Error != nil {
					out <- e
					continue
				}
				entries = append(entries, e.Entry)
			}
		}

		Sort(orders, entries)

		for _, e := range entries {
			select {
			case <-worker.Closing():
				return
			case out <- Result{Entry: e}:
			}
		}
	})
}
417319
func (a *DateHistogramAggregation) Order(order string, asc bool) *DateHistogramAggregation {
	a.order = order
	a.orderAsc = asc
	return a
}
519853
func (me *Dataset) Order(order ...OrderedExpression) *Dataset {
	ret := me.copy()
	ret.clauses.Order = orderList(order...)
	return ret
}
802806
func NewOrder(stmt *rel.SqlSelect) *Order {
	return &Order{Stmt: stmt, PlanBase: NewPlanBase(false)}
}
893049
func (s *DescribeFolderContentsInput) SetOrder(v string) *DescribeFolderContentsInput {
	s.Order = &v
	return s
}
1194261
func NewOrdering(dimensionsOrder []string) Ordering {
	dimensionOrderMap := make(map[string]int)
	for index, strVal := range dimensionsOrder {
		dimensionOrderMap[strVal] = index
	}
	return &orderedOrdering{
		dimensionOrderMap: dimensionOrderMap,
	}
}
1287642
func (b *Bittrex) CancelOrder(orderID string) (err error) {
	r, err := b.client.do("GET", "market/cancel?uuid="+orderID, "", true)
	if err != nil {
		return
	}
	var response jsonResponse
	if err = json.Unmarshal(r, &response); err != nil {
		return
	}
	err = handleErr(response)
	return
}
957036
func (sa *StorageAuthority) CountOrders(_ context.Context, _ int64, _, _ time.Time) (int, error) {
	return 0, nil
}
908164
func (s *PutRecordInput) SetSequenceNumberForOrdering(v string) *PutRecordInput {
	s.SequenceNumberForOrdering = &v
	return s
}
1057687
func NewOrder(ctx *plan.Context, p *plan.Order) *Order {
	o := &Order{
		TaskBase: NewTaskBase(ctx),
		p:        p,
		complete: make(chan bool),
	}
	return o
}
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
}
556977
func OrderR(a, b reflect.Value) int {
	if a.Kind() != b.Kind() {
		panic(&TypeError{a.Type(), b.Type(), "are not orderable because they are different kinds"})
	}

	switch a.Kind() {
	case reflect.Float32, reflect.Float64:
		a, b := a.Float(), b.Float()
		if a < b {
			return -1
		} else if a > b {
			return 1
		}
		return 0

	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		a, b := a.Int(), b.Int()
		if a < b {
			return -1
		} else if a > b {
			return 1
		}
		return 0

	case reflect.Uint, reflect.Uintptr, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		a, b := a.Uint(), b.Uint()
		if a < b {
			return -1
		} else if a > b {
			return 1
		}
		return 0

	case reflect.String:
		a, b := a.String(), b.String()
		if a < b {
			return -1
		} else if a > b {
			return 1
		}
		return 0
	}

	panic(&TypeError{a.Type(), nil, "is not orderable"})
}
580283
func (ps *pulloutSubquery) Reorder(order int) {
	ps.subquery.Reorder(order)
	ps.underlying.Reorder(ps.subquery.Order())
	ps.order = ps.underlying.Order() + 1
}
1252117
func order(order string) scope {
	return scopeFunc(func(db *gorm.DB) *gorm.DB {
		return db.Order(order)
	})
}
1010889
func (client *Client) CreateOrder(args *CreateOrderArgs) (resp CreateOrderResponse, err error) {
	response := CreateOrderResponse{}
	err = client.Invoke("CreateOrder", args, &response)
	return response, err
}
9161
func (a *DataTable) GenOrderBy(args ...func(string, string) string) string {
	return a.orders.Sql(args...)
}
281441
func (r Product_Order) GetResellerOrder(orderContainer *datatypes.Container_Product_Order) (resp datatypes.Container_Product_Order, err error) {
	params := []interface{}{
		orderContainer,
	}
	err = r.Session.DoRequest("SoftLayer_Product_Order", "getResellerOrder", params, &r.Options, &resp)
	return
}