import RandomSeed from 'random-seed'

function getDateString () {
  const date = new Date()

  const mm = date.getMonth() + 1
  const dd = date.getDate()

  return [
    date.getFullYear(),
    (mm > 9 ? '' : '0') + mm,
    (dd > 9 ? '' : '0') + dd
  ].join('')
}

export function deterministicShuffleForUserAndDay (user, array) {
  const rand = new RandomSeed(`${getDateString()}${user.id}`)

  const shuffledArray = []
  while (array.length > 0) {
    const element = rand.range(array.length)

    shuffledArray.push(
      array.splice(element, 1)[0]
    )
  }

  return shuffledArray
}

@@ -319,17 +319,25 @@
 er, 
-a
+originalA
 rray) %7B%0A
   co
@@ -328,24 +328,77 @@
 nalArray) %7B%0A
+  if (originalArray.length %3C 2) return originalArray%0A
   const rand
@@ -454,33 +454,105 @@
 %0A%0A  
-const shuffledArray = %5B%5D%0A
+let shuffledArray, array;%0A  do %7B%0A    shuffledArray = %5B%5D%0A    array = _.cloneDeep(originalArray)%0A  
   wh
@@ -580,16 +580,18 @@
 ) %7B%0A    
+  
 const el
@@ -624,24 +624,26 @@
 ength)%0A%0A    
+  
 shuffledArra
@@ -650,16 +650,18 @@
 y.push(%0A
+  
       ar
@@ -694,13 +694,69 @@
     
+  
 )%0A  
+ 
-%7D
+ %7D%0A  %7D while (_.isEqual(shuffledArray, originalArray))
 %0A%0A  

Make sure that deterministicShuffleForUserAndDay doesn't return original order (#636)