Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
Cómo ordenar la lista de opciones en orden alfabético en ReactJS

Principiante en JavaScript y ReactJs. Estoy tratando de ordenar esta lista mientras muestro opciones en la parte delantera.

 <Select value={Reactivity} options={[ { label: "Chicken", value: "Chicken" }, { label: "Rat", value: "Rat" }, { label: "Dog", value:"Dog"}, { label: "Pig", value:"Pig"}, ]} placeholder="Reactivity" onChange={(v) => { setReactivity(v.map((vv) => vv)); }} isClearable isMulti />

// Código para mostrar y elegir opciones

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Puedes usar Array.sort

 <Select value={Reactivity} options={[ { label: "Chicken", value: "Chicken" }, { label: "Rat", value: "Rat" }, { label: "Dog", value:"Dog"}, { label: "Pig", value:"Pig"}, ].sort((a, b) => a.label.localeCompare(b.label))} placeholder="Reactivity" onChange={(v) => { setReactivity(v.map((vv) => vv)); }} isClearable isMulti />
about 4 years ago · Santiago Gelvez Report

0

Puede leer más sobre sort() y localeCompare() .

Puedes hacer algo como esto:

 <Select value={Reactivity} options={() => [ { label: "Chicken", value: "Chicken" }, { label: "Rat", value: "Rat" }, { label: "Dog", value:"Dog"}, { label: "Pig", value:"Pig"}, ].sort((a, b) => a.label.localeCompare(b.label)) } placeholder="Reactivity" onChange={(v) => { setReactivity(v.map((vv) => vv)); }} isClearable isMulti />
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!