title: Java : How do I print an ascending column and next to that column the same set of integers except in descending order all in one single text file
body: <p>I need some help in how to do a certain step as I can not seem to figure it out.
  I was given a text file with 100 numbers in it all random, I am supposed to sort them either in ascending order, descending order, or both depending on the user input. Then which ever the user inputs the set of integers will be sorted and printed in a text file. I am having trouble printing the both file. Here is my code up until the both statement.</p>
  
  <pre><code>public static void print(ArrayList&lt;Integer&gt; output, String destination){
      try {
          PrintWriter print = new PrintWriter(destination);
          for(int i = 0; i &lt; output.size(); i++){
              print.print(output.get(i) + " ");
          }
          print.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  
  
  public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      BufferedReader br = null;
      ArrayList&lt;Integer&gt; words = new ArrayList&lt;&gt;();
      BufferedReader reader;
      String numbers;
  
      try {
          reader = new BufferedReader(new FileReader("input.txt"));
  
          while((numbers = reader.readLine()) != null)
          {
              words.add(Integer.parseInt(numbers));
          }
  
          System.out.println("How would you like to sort?");
          System.out.println("Please enter asc(For Ascending), desc(For Decending), or both");
          String answer = input.next();
  
          Collections.sort(words);
  
          if(answer.equals("asc")){
              Collections.sort(words);
              System.out.println(words);
              print(words,"asc.txt");
          }
          else if(answer.equals("desc")){
              Collections.reverse(words);
              System.out.println(words);
              print(words,"desc.txt");
  </code></pre>
  
  <p>When I type in "both" the text file that is created only has one column set of integers that is going in descending order, not both and I have no idea how to print both sets. If someone could shed some light I would really appreciate it.</p>
  
  <pre><code>else if(answer.equals("both")){
              System.out.println(words);
              print(words,"both.txt");
              Collections.reverse(words);
              System.out.println(words);
              print(words,"both.txt");
  </code></pre>