// OrderR is equivalent to Order, but operates on reflect.Values.
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"})
}
1220334
func (s *ListQueuesInput) SetOrder(v string) *ListQueuesInput {
	s.Order = &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
}
644908
func (b *SelectStmt) OrderDir(col string, isAsc bool) *SelectStmt {
	if isAsc {
		b.OrderAsc(col)
	} else {
		b.OrderDesc(col)
	}
	return b
}
333584
func (s *ListCompilationJobsInput) SetSortOrder(v string) *ListCompilationJobsInput {
	s.SortOrder = &v
	return s
}
1245382
func (s *SortCriterion) SetSortOrder(v string) *SortCriterion {
	s.SortOrder = &v
	return s
}
333398
func (s *DescribeUsersInput) SetOrder(v string) *DescribeUsersInput {
	s.Order = &v
	return s
}
670955
func (sq *subquery) Reorder(order int) {
	sq.input.Reorder(order)
	sq.order = sq.input.Order() + 1
}
1100039
func (jb *join) Reorder(order int) {
	jb.Left.Reorder(order)
	jb.leftOrder = jb.Left.Order()
	jb.Right.Reorder(jb.leftOrder)
	jb.order = jb.Right.Order() + 1
}
1367329
func (s *SnapshotSortingEntity) SetSortOrder(v string) *SnapshotSortingEntity {
	s.SortOrder = &v
	return s
}
1010889
func (client *Client) CreateOrder(args *CreateOrderArgs) (resp CreateOrderResponse, err error) {
	response := CreateOrderResponse{}
	err = client.Invoke("CreateOrder", args, &response)
	return response, err
}
314524
func (b *SelectBuilder) OrderBy(exprs ...interface{}) *SelectBuilder {
	b.Select.OrderBy = makeOrderBy(exprs...)
	return b
}
917984
func (statement *Statement) OrderBy(order string) *Statement {
	if len(statement.OrderStr) > 0 {
		statement.OrderStr += ", "
	}
	statement.OrderStr += order
	return statement
}
524096
func (s *ComputeEnvironmentOrder) SetOrder(v int64) *ComputeEnvironmentOrder {
	s.Order = &v
	return s
}
528313
func (p *MemPostings) EnsureOrder() {
	p.mtx.Lock()
	defer p.mtx.Unlock()

	if p.ordered {
		return
	}

	n := runtime.GOMAXPROCS(0)
	workc := make(chan []uint64)

	var wg sync.WaitGroup
	wg.Add(n)

	for i := 0; i < n; i++ {
		go func() {
			for l := range workc {
				sort.Slice(l, func(i, j int) bool { return l[i] < l[j] })
			}
			wg.Done()
		}()
	}

	for _, e := range p.m {
		for _, l := range e {
			workc <- l
		}
	}
	close(workc)
	wg.Wait()

	p.ordered = true
}
239010
func (s *ListJobsInput) SetOrder(v string) *ListJobsInput {
	s.Order = &v
	return s
}
85453
func (sa *StorageAuthority) GetOrder(_ context.Context, req *sapb.OrderRequest) (*corepb.Order, error) {
	if *req.Id == 2 {
		return nil, berrors.NotFoundError("bad")
	} else if *req.Id == 3 {
		return nil, errors.New("very bad")
	}

	status := string(core.StatusValid)
	one := int64(1)
	serial := "serial"
	exp := sa.clk.Now().AddDate(30, 0, 0).Unix()
	validOrder := &corepb.Order{
		Id:                req.Id,
		RegistrationID:    &one,
		Expires:           &exp,
		Names:             []string{"example.com"},
		Status:            &status,
		Authorizations:    []string{"hello"},
		CertificateSerial: &serial,
		Error:             nil,
	}

	// Order ID doesn't have a certificate serial yet
	if *req.Id == 4 {
		pending := string(core.StatusPending)
		validOrder.Status = &pending
		validOrder.Id = req.Id
		validOrder.CertificateSerial = nil
		validOrder.Error = nil
		return validOrder, nil
	}

	// Order ID 6 belongs to reg ID 6
	if *req.Id == 6 {
		six := int64(6)
		validOrder.Id = req.Id
		validOrder.RegistrationID = &six
	}

	// Order ID 7 is ready, but expired
	if *req.Id == 7 {
		ready := string(core.StatusReady)
		validOrder.Status = &ready
		exp = sa.clk.Now().AddDate(-30, 0, 0).Unix()
		validOrder.Expires = &exp
	}

	if *req.Id == 8 {
		ready := string(core.StatusReady)
		validOrder.Status = &ready
	}

	return validOrder, nil
}