0

I have a method readData() that reads the data in correctly from a text chosen text file. And correctly outputs the results. An example of this file data is:

{Clothes}

  • 15.00,Black, Female
  • 30.00,Yellow, Female
  • 50.00,Green, Male
  • 90.00,Orange, Female

{Shoes}

  • 75.00,Black, Female, Nike
  • 55.00,White, Male, Adidas

{Clothes}

  • 22.00,Blue, Male
  • 32.00,Black, Female

The type of object or data identified through the {type of data}. And when I print out the data everything prints out. However, Clothes is printed out more than once because there is two different types of them. What I want to do is to sort the array list so that all the clothes objects appear under one heading and all the shoes objects appear under one heading. Is there any methods you recommend that would get me started on this? Thanks for the help.

Nick Low
  • 13
  • 4
  • *"Is there any methods you recommend?"* Yes: [`sort()`](https://docs.oracle.com/javase/8/docs/api/java/util/List.html#sort-java.util.Comparator-). Or [`Collections.sort()`](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#sort-java.util.List-java.util.Comparator-) if you're pre-Java 8. – Andreas Mar 21 '17 at 03:06
  • Wow! That duplicate has almost exactly the same title as your question. If only you could have searched for it, huh... – Andreas Mar 21 '17 at 03:09

0 Answers0