Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
Best way to handle number dictionary keys in typescript

I have a simple typed dictionary:

let frecuencies: {[price: number]: number } = {};

I need to get the keys, sort them in a numberical way and run through them in a loop taking into acount that the type of the keys is number:

let keys = Object.keys(frecuencies);
keys = keys.sort();

This obvioulsy doesn't work because Object.keys returns an array of strings. I know I could pass a function to the sort function to sort in a numerical way, but is there any way to keep the keys typing when getting the keys? Something like this:

let keys: number[] = Object.keys<number>(frecuencies);

Does exist something like that?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda