title: How to Shuffle a List in Scala
body: <p>I am trying to read a text file and append its values to an array and print its elements randomly to the screen.</p>
  
  <p>I am using Random from the util library but it's not outputting as expected.</p>
  
  <p>Below is my code</p>
  
  <pre><code>import scala.io.Source
  import scala.util.Random
  
  object Scala  
  { 
  
      def main(args: Array[String])  
      { 
          val lines = Source.fromFile("text.txt").getLines.toArray
          val modified_lines = Random.shuffle(List(lines))
          for (line &lt;- modified_lines) {
              println(line)
          }
  
      } 
  } 
  </code></pre>
  
  <p>and I have a text file that contains</p>
  
  <pre><code>1. ABC
  2. ABC
  3. ABC
  4. ABC
  5. ABC
  6. ABC
  </code></pre>
  
  <p>So in the end I'd like to print them to the screen such as</p>
  
  <pre><code>5. ABC
  2. ABC
  ...
  6. ABC
  </code></pre>