title: shuffle array in ng-repeat angular
body: <p>I'm creating a quiz and every time I start the quiz I want to shuffle the questions, so that they won't appear in the same order every time.</p>
  <p>I have this in my html code:</p>
  <pre><code>&lt;div ng-repeat=&quot;question in questions | filter:ids | orderBy:randomSort&quot;&gt;
      &lt;div id=&quot;question&quot;&gt;{{question.question}}&lt;/div&gt;&lt;img id=&quot;nextImg&quot; ng-src=&quot;../app/img/next.png&quot; ng-click=&quot;next()&quot; /&gt;
      &lt;img class=&quot;quizImg&quot; ng-hide=&quot;{{question.image}}==null&quot; ng-src=&quot;{{question.image}}&quot; /&gt;
  
      &lt;div class=&quot;answer&quot; ng-repeat=&quot;answer in question.answers&quot;&gt;
          &lt;input type=&quot;radio&quot; ng-click=&quot;checked(answer)&quot;&gt;{{answer.answer}}
      &lt;/div&gt;
      &lt;!--input id=&quot;nextQuestion&quot; type=&quot;button&quot; ng-click=&quot;next()&quot; value=&quot;{{buttonText}}&quot;--&gt;
  &lt;/div&gt;
  </code></pre>
  <p>and this in my controller</p>
  <pre><code> lycheeControllers.controller('quizCtrl', ['$scope', '$http', function ($scope, $http) {
      $http.get('json/questions.json').success(function (data) {
          //all questions
          $scope.questions = data;
  
          $scope.titel = &quot;Check your knowledge about lychees&quot;
  
  
          $scope.randomSort = function(question) {
                        return Math.random();
                      };
  
          //filter for getting answers / question
          $scope.ids = function (question) {
              return question.id == number;
          }
  
          $scope.find = function (id) {
              if (id == number) {
                  return true;
              }
          }
  
  
          $scope.next = function () {
              if (!(number == (data.length))) {
                  //questionId++;
                  number++;
                  if (correct == true) {
                      points++;
                  }
                  //alert(points);
              } else {
                  if (!end) {
                      if (correct == true) {
                          points++;
                          end = true;
                      }
                  }
  
                  alert(&quot;Quiz finished: your total score is: &quot; + points);
              }
              correct = false;
          }
  
          $scope.checked = function (answer) {
              //alert(answer.answer);
  
              if (answer.correct == &quot;yes&quot;) {
                  correct = true;
              } else {
                  correct = false;
              }
  
              //alert(correct);
          }
  
  
      });
  
  }])
  ;
  </code></pre>
  <p>unfortunately this isn't working at all..</p>