Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
Javascript: How to rearrange array of objects based on conditions

I implemented sort in alphabetical order and wanted rearrange the objects (move all status red object to the bottom of the array. How I can move all status red data to end of the array in from my onLoad function?

// sample data
const data = [
  {
    status: "green",
    name: "alex"
  },
  {
    status: "red",
    name: "ken"
  },
  {
    status: "red",
    name: "roy"
  },
  {
    status: "green",
    name: "boy"
  }
]

users: User[];

// get list
onLoad() {
    this.service.getList$
        .pipe(takeUntil(this._unsubscribeAll))
        .subscribe((users: User[]) => {
            this.users = users;
                .sort((a, b) => 0 - (a.name > b.name ? -1 : 1));
        });
}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda