Ranking order in array

Hi Expert,

i am using some analytic tools to predict a modal result, there will be only 3 result , A_result, B_result & C_result, array just like below

{
“A_result”=0.6,
“B_result”=0.3,
“C_result”=0.1
}

And array item sequence based on the result probability, the highest probability will come first, so some times the C_result may appear in the first place.

{
“C_result”=0.7,
“B_result”=0.2,
“A_result”=0.1
}

My question is how can i transform the array alway be in alphabetical order regardless the probability? then i can easily do some calculation on next step!!

thanks

Hi @Louis_kwok, can you confirm the full JSON data structure you’re currently working with in n8n? You can extract it like so:

Recording 2022-08-29 at 11.35.32

On a very general level, the order of object keys is not guaranteed in Javascript and you might want to consider using a genuine array instead. But let’s take a look at the data you’re processing first :slight_smile: