I have in my variable optionsPergunta one array options of objects that I need to sort:
I've tryed something like:
optionsPergunta.sort(this.sorteiaArray)
sorteiaArray(){
   return Math.random() < Math.random()
}
But when i do a console.log(optionsPergunta.options) the positions haven't changed
the optionsPergunta is the result of a query, so when i do a console.log(optionsPergunta) i'm having this result:
[
  BookUnitQuestionOption {
    __setters__: [
      '$attributes',
      '$persisted',
      'primaryKeyValue',
      '$originalAttributes',
      '$relations',
      '$sideLoaded',
      '$parent',
      '$frozen',
      '$visible',
      '$hidden'
    ],
    '$attributes': {
      id: 6,
      book_unit_question_id: 2,
      description: 'get',
      image_sound: null,
      correct: true,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:27.000Z,
      updated_at: 2019-12-27T19:06:27.000Z
    },
    '$persisted': true,
    '$originalAttributes': {
      id: 6,
      book_unit_question_id: 2,
      description: 'get',
      image_sound: null,
      correct: true,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:27.000Z,
      updated_at: 2019-12-27T19:06:27.000Z
    },
    '$relations': {},
    '$sideLoaded': {},
    '$parent': null,
    '$frozen': false,
    '$visible': undefined,
    '$hidden': undefined
  },
  BookUnitQuestionOption {
    __setters__: [
      '$attributes',
      '$persisted',
      'primaryKeyValue',
      '$originalAttributes',
      '$relations',
      '$sideLoaded',
      '$parent',
      '$frozen',
      '$visible',
      '$hidden'
    ],
    '$attributes': {
      id: 9,
      book_unit_question_id: 2,
      description: 'stay',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:45.000Z,
      updated_at: 2019-12-27T19:06:45.000Z
    },
    '$persisted': true,
    '$originalAttributes': {
      id: 9,
      book_unit_question_id: 2,
      description: 'stay',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:45.000Z,
      updated_at: 2019-12-27T19:06:45.000Z
    },
    '$relations': {},
    '$sideLoaded': {},
    '$parent': null,
    '$frozen': false,
    '$visible': undefined,
    '$hidden': undefined
  },
  BookUnitQuestionOption {
    __setters__: [
      '$attributes',
      '$persisted',
      'primaryKeyValue',
      '$originalAttributes',
      '$relations',
      '$sideLoaded',
      '$parent',
      '$frozen',
      '$visible',
      '$hidden'
    ],
    '$attributes': {
      id: 5,
      book_unit_question_id: 2,
      description: 'are',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:21.000Z,
      updated_at: 2019-12-27T19:06:33.000Z
    },
    '$persisted': true,
    '$originalAttributes': {
      id: 5,
      book_unit_question_id: 2,
      description: 'are',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:21.000Z,
      updated_at: 2019-12-27T19:06:33.000Z
    },
    '$relations': {},
    '$sideLoaded': {},
    '$parent': null,
    '$frozen': false,
    '$visible': undefined,
    '$hidden': undefined
  },
  BookUnitQuestionOption {
    __setters__: [
      '$attributes',
      '$persisted',
      'primaryKeyValue',
      '$originalAttributes',
      '$relations',
      '$sideLoaded',
      '$parent',
      '$frozen',
      '$visible',
      '$hidden'
    ],
    '$attributes': {
      id: 8,
      book_unit_question_id: 2,
      description: 'move',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:43.000Z,
      updated_at: 2019-12-27T19:06:43.000Z
    },
    '$persisted': true,
    '$originalAttributes': {
      id: 8,
      book_unit_question_id: 2,
      description: 'move',
      image_sound: null,
      correct: false,
      status: false,
      user_id: 1,
      created_at: 2019-12-27T19:06:43.000Z,
      updated_at: 2019-12-27T19:06:43.000Z
    },
    '$relations': {},
    '$sideLoaded': {},
    '$parent': null,
    '$frozen': false,
    '$visible': undefined,
    '$hidden': undefined
  }
]
When i return the result, and test in postman i have this:
[
  {
    "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": 9,
    "book_unit_question_id": 2,
    "description": "stay",
    "image_sound": null,
    "correct": false,
    "status": false,
    "user_id": 1,
    "created_at": "2019-12-27 16:06:45",
    "updated_at": "2019-12-27 16:06:45"
  },
  {
    "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": 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"
  }
]
 
     
    