// reorderArgs moves all flags before arguments as this is what flag expects
541478
func reorderArgs(args []string) []string {
	var nonflags, flags []string

	readFlagValue := false
	for i, arg := range args {
		if arg == "--" {
			nonflags = append(nonflags, args[i:]...)
			break
		}

		if readFlagValue && !strings.HasPrefix(arg, "-") && !strings.HasPrefix(arg, "--") {
			readFlagValue = false
			flags = append(flags, arg)
			continue
		}
		readFlagValue = false

		if arg != "-" && strings.HasPrefix(arg, "-") {
			flags = append(flags, arg)

			readFlagValue = !strings.Contains(arg, "=")
		} else {
			nonflags = append(nonflags, arg)
		}
	}

	return append(flags, nonflags...)
}
524096
func (s *ComputeEnvironmentOrder) SetOrder(v int64) *ComputeEnvironmentOrder {
	s.Order = &v
	return s
}
1105924
func (b *PQueue) Requeue(priority int, message *Message) error {
	if message.key == nil {
		return fmt.Errorf("Cannot requeue new message")
	}
	return b.enqueueMessage(priority, message.key, message)
}
19915
func (s *SearchInput) SetSortOrder(v string) *SearchInput {
	s.SortOrder = &v
	return s
}
725433
func (s *ListApplicationRevisionsInput) SetSortOrder(v string) *ListApplicationRevisionsInput {
	s.SortOrder = &v
	return s
}
1070598
func (s *Order) SetSortOrder(v int64) *Order {
	s.SortOrder = &v
	return s
}
850233
func Reorder(name, description string, data *d.UserTypeDefinition, position *d.UserTypeDefinition) *d.MediaTypeDefinition {
	return a.MediaType("application/vnd."+strings.ToLower(name)+"json", func() {
		a.UseTrait("jsonapi-media-type")
		a.TypeName(name + "Reorder")
		a.Description(description)
		a.Attribute("data", a.ArrayOf(data))
		a.Attribute("position", position)
		a.View("default", func() {
			a.Attribute("data")
			a.Required("data")
		})
	})
}
652775
func (s *ListBuildsInput) SetSortOrder(v string) *ListBuildsInput {
	s.SortOrder = &v
	return s
}
952591
func SetOrdererEnv(cmd *cobra.Command, args []string) {
	// read in the legacy logging level settings and, if set,
	// notify users of the FABRIC_LOGGING_SPEC env variable
	var loggingLevel string
	if viper.GetString("logging_level") != "" {
		loggingLevel = viper.GetString("logging_level")
	} else {
		loggingLevel = viper.GetString("logging.level")
	}
	if loggingLevel != "" {
		mainLogger.Warning("CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable")
	}
	// need to init logging here as cobra does not currently support
	// chaining PersistentPreRun functions
	loggingSpec := os.Getenv("FABRIC_LOGGING_SPEC")
	flogging.InitFromSpec(loggingSpec)
	// set the orderer environment from flags
	viper.Set("orderer.tls.rootcert.file", caFile)
	viper.Set("orderer.tls.clientKey.file", keyFile)
	viper.Set("orderer.tls.clientCert.file", certFile)
	viper.Set("orderer.address", OrderingEndpoint)
	viper.Set("orderer.tls.serverhostoverride", ordererTLSHostnameOverride)
	viper.Set("orderer.tls.enabled", tlsEnabled)
	viper.Set("orderer.tls.clientAuthRequired", clientAuth)
	viper.Set("orderer.client.connTimeout", connTimeout)
}
118797
func (s *Server) SetRetries(count int) {
	if count < 1 {
		s.retries = defaultRetries
	} else {
		s.retries = count
	}
}
85737
func (s *UsageService) GenerateUsageRecords(p *GenerateUsageRecordsParams) (*GenerateUsageRecordsResponse, error) {
	resp, err := s.cs.newRequest("generateUsageRecords", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r GenerateUsageRecordsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
218455
func (e *TokensController) retryOrForget(queue workqueue.RateLimitingInterface, key interface{}, requeue bool) {
	if !requeue {
		queue.Forget(key)
		return
	}

	requeueCount := queue.NumRequeues(key)
	if requeueCount < e.maxRetries {
		queue.AddRateLimited(key)
		return
	}

	klog.V(4).Infof("retried %d times: %#v", requeueCount, key)
	queue.Forget(key)
}
1096604
func reorderBodyForClosures(arity func(Ref) int, globals VarSet, body Body) (Body, unsafeVars) {

	reordered := Body{}
	unsafe := unsafeVars{}

	for {
		n := len(reordered)

		for _, e := range body {
			if reordered.Contains(e) {
				continue
			}

			// Collect vars that are contained in closures within this
			// expression.
			vs := VarSet{}
			WalkClosures(e, func(x interface{}) bool {
				vis := &VarVisitor{vars: vs}
				Walk(vis, x)
				return true
			})

			// Compute vars that are closed over from the body but not yet
			// contained in the output position of an expression in the reordered
			// body. These vars are considered unsafe.
			cv := vs.Intersect(body.Vars(safetyCheckVarVisitorParams)).Diff(globals)
			uv := cv.Diff(outputVarsForBody(reordered, arity, globals))

			if len(uv) == 0 {
				reordered = append(reordered, e)
				delete(unsafe, e)
			} else {
				unsafe.Set(e, uv)
			}
		}

		if len(reordered) == n {
			break
		}
	}

	return reordered, unsafe
}
1111452
func (charts *ChartData) ReorgHandler(wg *sync.WaitGroup, c chan *txhelpers.ReorgData) {
	defer func() {
		wg.Done()
	}()
	for {
		select {
		case data, ok := <-c:
			if !ok {
				return
			}
			commonAncestorHeight := uint64(data.NewChainHeight) - uint64(len(data.NewChain))
			charts.mtx.Lock()
			defer charts.mtx.Unlock()
			charts.Blocks.Snip(int(commonAncestorHeight) + 1)
			// Snip the last two days
			daysLen := len(charts.Days.Time)
			daysLen -= 2
			charts.Days.Snip(daysLen)
			// Drop the last window
			windowsLen := len(charts.Windows.Time)
			windowsLen--
			charts.Windows.Snip(windowsLen)
			data.WG.Done()

		case <-charts.ctx.Done():
			return
		}
	}
}
384948
func (s *GetWorkflowExecutionHistoryInput) SetReverseOrder(v bool) *GetWorkflowExecutionHistoryInput {
	s.ReverseOrder = &v
	return s
}
1032898
func sortTriggers(t []*internal.Trigger) {
	sort.Slice(t, func(i, j int) bool { return isTriggerOlder(t[i], t[j]) })
}
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)
}