1 Reply Latest reply: Oct 28, 2009 7:22 PM by 843789 RSS

    sort a file

    843789
      I have a file that has 50000 entries/records. Each line is a number. I would like to apply a sort algorithm to this file. Basically java program will read the file and sort it using selection sort algorithm.

      should I be reading the file into an array? what other data structure can I use ???
        • 1. Re: sort a file
          843789
          You could just use the text file sort tool provided by the OS (e.g., unix "sort"), and not even write a program.

          If you had to write a program in Java, you'd be best off reading the file into a java.util.List and then use Collections.sort, and not write your own sort implementation at all.

          If you had to write your own sort implementation...then do that.