I am facing a rather unusual problem using _.object(underscore library call). Below is my code :
var sortable = [ [ 'c', 107 ],[ 'd', 59 ],[ 'e', 53 ],[ '5', 53 ],[ '6', 26 ],[ '3', 19 ],[ 'a', 10 ],[ '8', 7 ],[ '2', 5 ], [ '7', 4 ],[ '1', 3 ], [ '9', 3 ]];
sortDict = _.object(sortable);
My output should be :
sortDict = { 'c':107 ,'d': 59,'e': 53 ,'5': 53,'6': 26,'3': 19,'a':10,'8': 7 ,'2':5, '7': 4,'1': 3, '9': 3 }
But what I am getting has me confused, see the output below :
sortDict = {'1': 3, '2':5, '3': 19, '5': 53, '6': 26, '7': 4, '8': 7 , '9': 3 , 'c':107 , 'd': 59, 'e': 53 , 'a':10 }
I am just trying to convert an array to an object here, but the order seems to have changed. Can you please help me achieve my desired output by any means.