0
Javascript: Help needed
I was working on this code base quick but the third optional parameter of { sorted: 0 || 1} is not working as expected. What could be the reason?? https://sololearn.com/compiler-playground/c754zmX7j1fw/?ref=app
5 ответов
+ 1
Can you elaborate further on what "is not working as expected"?
I understand the grouping part, but how should the result be sorted? is it sorted by the group name (gender, age etc.)
Does group's members get sorted as well? by which key?
Adding an illustration of the resulting array arrangement in post Description might help post viewers to better understand how the desired result should be.
+ 1
Ipang, thanks 😊...
I got help from a colleague.
Though for interest, {sorted: 0} should order the keys of the final object in descending order and {sorted: 1} ascending order...
i.e
// {sorted: 1}
{
'Female': ' [ ......],
'Male': ' [........]
}
// {sorted: 0}
{
'Male': ' [ ......],
'Female': ' [........]
}
+ 1
Good job!
Now I understand what you mean, thanks to the illustration :)
Not that it matters, I was just wondering whether it was due to the branch at line 11; cause that would be the first thing I'd take a closer look at.
Never mind :D
0
Thanks for providing an update and feedback. I'm happy you got things sorted.
0
Chris Coder Always