module Data.Tensort.Utils.RandomizeList (randomizeList) where
import Data.Tensort.Utils.Types (Sortable (..))
import System.Random (mkStdGen)
import System.Random.Shuffle (shuffle')
randomizeList :: Int -> Sortable -> Sortable
randomizeList :: Int -> Sortable -> Sortable
randomizeList Int
seed (SortBit [Int]
xs) = [Int] -> Sortable
SortBit ([Int] -> Int -> StdGen -> [Int]
forall gen a. RandomGen gen => [a] -> Int -> gen -> [a]
shuffle' [Int]
xs ([Int] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Int]
xs) (Int -> StdGen
mkStdGen Int
seed))
randomizeList Int
seed (SortRec [Record]
xs) = [Record] -> Sortable
SortRec ([Record] -> Int -> StdGen -> [Record]
forall gen a. RandomGen gen => [a] -> Int -> gen -> [a]
shuffle' [Record]
xs ([Record] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Record]
xs) (Int -> StdGen
mkStdGen Int
seed))