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

23rd Jul 2024, 12:08 PM
Ssekandi Raymond
Ssekandi Raymond - avatar
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.
24th Jul 2024, 3:18 AM
Ipang
+ 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': ' [........] }
24th Jul 2024, 7:20 PM
Ssekandi Raymond
Ssekandi Raymond - avatar
+ 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
25th Jul 2024, 2:47 AM
Ipang
0
Thanks for providing an update and feedback. I'm happy you got things sorted.
24th Jul 2024, 9:09 PM
Chris Coder
Chris Coder - avatar
0
24th Jul 2024, 9:23 PM
Ssekandi Raymond
Ssekandi Raymond - avatar