Курсор метеора игнорирует параметр сортировки

#javascript #mongodb #sorting #reactjs #meteor

#javascript #mongodb #сортировка #reactjs #метеор

Вопрос:

Я использую Meteor с React и react-meteor-data . Я пытаюсь заставить Videos.find(...) функцию возвращать массив, отсортированный по его полю «индекс». Смотрите мой код ниже.

Первый console.log() выводит массив, правильно отсортированный. Второй console.log() выводит массив в порядке по умолчанию. Даже если я изменю параметр сортировки, он, похоже, игнорируется. Я не могу понять, как videos отсортировать эту константу.

 export default DashboardContainer = createContainer(props => {
  const videosHandle = Meteor.subscribe('userVideos');
  const loading = !videosHandle.ready();
  const videos = !loading ? Videos.find({}, {fields: {title:1, subtitle:1,
    duration:1, thumb:1, url:1, index:1, groups:1}, sort: {index:1}}).fetch() : [];

  // logs the array properly sorted by the index field of the elements
  console.log(Videos.find({}, {fields: {title:1, subtitle:1, duration:1, thumb:1, url:1, index:1, groups:1}, sort: {index:1}}).fetch());

  // logs the array unsorted (unwanted behaviour)
  console.log(videos);

  return {
   loading,
   videos,
  };
}, Dashboard);
  

Обновить:

Если я использую console.log(videos.map((i) => i.index)); вместо console.log(videos) , я получаю список, напечатанный в правильном порядке:

[1,2,3,4,5...]

Почему ?!