0
I have in the variable optionsPergunta
an object array and need to draw the position of the objects in this array:
"options": [
{
"id": 6,
"book_unit_question_id": 2,
"description": "get",
"image_sound": null,
"correct": true,
"status": false,
"user_id": 1,
"created_at": "2019-12-27 16:06:27",
"updated_at": "2019-12-27 16:06:27"
},
{
"id": 5,
"book_unit_question_id": 2,
"description": "are",
"image_sound": null,
"correct": false,
"status": false,
"user_id": 1,
"created_at": "2019-12-27 16:06:21",
"updated_at": "2019-12-27 16:06:33"
},
{
"id": 7,
"book_unit_question_id": 2,
"description": "go to",
"image_sound": null,
"correct": false,
"status": false,
"user_id": 1,
"created_at": "2019-12-27 16:06:39",
"updated_at": "2019-12-27 16:06:39"
},
{
"id": 8,
"book_unit_question_id": 2,
"description": "move",
"image_sound": null,
"correct": false,
"status": false,
"user_id": 1,
"created_at": "2019-12-27 16:06:43",
"updated_at": "2019-12-27 16:06:43"
}
]
I tried something like:
optionsPergunta.sort(this.sorteiaArray)
sorteiaArray(){
return Math.random() < Math.random()
}
But when showing the content of optionsPergunta, I remain with the objects in the same position.
Maybe it’s not clear to me, it’s all positions or you want to take a position at random?
– novic
I believe that by "draw" you mean "order". If so, by which field would you like to order?
– eldes