How can i read a text file and still sort the information in it using iterators in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i read a text file and still sort the information in it using iterators in java?

assignment

22nd Feb 2018, 6:58 AM
Mbiraru
Mbiraru - avatar
4 Answers
+ 4
You can use Scanner or BufferedReader to read info from file. Store it in an arrayList and then use Collections.sort() on the arrayList. Also you can store it in an array and use an sorting algorithm like selection sort or quick sort. If you have many details like the name, dob, etc, you probably have to store each attribute in its own array and then you can sort based on any attribute.
2nd Mar 2018, 12:11 PM
Tejaswi Hegde
Tejaswi Hegde - avatar
+ 3
I didn't understand your question. Could u give an example?
2nd Mar 2018, 5:11 AM
Tejaswi Hegde
Tejaswi Hegde - avatar
0
Let's say you are given a text file containing information about swimmers.It has swimmers name,date of birth,status which is qualified or did not qualify and time they finished swimming.The information is randomly inserted. My question is how can i read and sort that information using java?
2nd Mar 2018, 12:03 PM
Mbiraru
Mbiraru - avatar
0
just learn to explore upon it and you will get the answer😊
9th Mar 2018, 1:37 AM
Baltazar Pader
Baltazar  Pader - avatar