I have an array of objects with 11 properties and I want to shuffle the properties appearing in the array in a random way.
To be clear, the order of the array objects will be the same. I want to randomize the properties order inside the object and keep this order for every object.
Here is a sample of my Array:
I tried looking for any other solution to similar problems but most of them were rearanging the object whereas I need to randomize the properties
var list = [
{
"ID": 0,
"Name": "Mark",
"Address": "2323 st",
"Phone": 511 232 2000,
"Score": 345
},
{
"ID": 1,
"Name": "Catrina",
"Address": "2323 st",
"Phone": 511 232 2100,
"Score": 3452
} //and 1000 more objects...
And this is what I am looking for (the order should be rearranged when clicking a button)
var list2 = [
{
"Score": 345
"Name": "Mark",
"Address": "2323 st",
"ID": 0,
"Phone": 511 232 2000,
},
{
"Score": 3452
"Name": "Catrina",
"Address": "2323 st",
"ID": 1,
"Phone": 511 232 2100,
} //and 1000 more objects...
I want to get an output of list2 with the same data but in a random property order. The randomize function would be called whenever someone clicks a button, this I'll be able to do once I find a way to have a function the does what I want.